1 6 7 8 9 10 43 Previous Next

ABAP Development

634 Posts

Introduction to BDT:

The BDT (Business Data Toolset) is a central control tool for maintaining master data and simple transaction data. In addition to dialog maintenance, it also supports maintenance with direct input and/or function modules.


The BDT also provides generic services for consistently recurring requirements such as occur in change document lists, field groupings and the deletion program. It takes control over these objects as well as generic parts and calls the applications using predefined interfaces (control tables and events). The applications themselves introduce application-specific enhancements, such as writing and reading application tables


BDT settings:


Step 1: Create Module Pool Program - SAPLZFG_FSCM with screen 9001.

(Function Group: ZFG_FSCM)

 

 

Step 2: Create New Application for screen

BUPT->Business Partner->Control->Applications / t-code (BUS1)

 

Step 3: Create New Dataset for the application:

BUPT->Business Partner->Control->Data Sets / t-code (BUS23)

 

Step 4: Create field groups as required:

BUPT->Business Partner->Control->Screen Layout->Field Groups / t-code (BUS2)

 

Assign the fields to the field group

 

Step 5: Create view:

BUPT->Business Partner->Control->Screen Layout->Views / t-code (BUS3)

 

Assign the field groups to the views:

 

Step 6: Create section

Go to BUPT->Business Partner->Control->Screen Layout->Section/ t-code (BUS4)

 

Assign View to the section:

 

Step 7: Create Screen:

Go to BUPT->Business Partner->Control->Screen Layout->Screens (BUS5)

 

Assign the section to the screen


 

Step 8: Create the screen sequence:

Go to BUPT->Business Partner->Control->Screen Sequences (BUS6)

 

Select the screen sequence and click on Screen Sequence->Screens to assign the Screen.

 

 

Create a screen sequence category:

 

Selecting the Screen Sequence category, assign the screen sequence to it.


 

Step 9:

Add your screen with the standard screen sequence so that it would appear with the standard TABS.

Select the BUP001 Screen Sequence and add your screen with the required Item number.

Item Number will depict where the tab will come.


 

**************Most Important Step******************

Step 10: Create Divisibility:

BUPT->Business Partner->Control->Divisibility->BP Views (BUSD)


Add Data Set ZFSCM to standard BP View UKM000


 

Add the custom application to standard BP view UKM000

 

Output: Execute t-code “UKM_BP” and enter partner number.

 

 

Incorporating a logic flow for the validations etc. of those custom fields

To incorporate the logic for the validations of the custom fields, the PAI and the PBO of the custom program that is attached to the View can be used.

Here we attached the custom FM “ZZAPP_BUPA_PBO_ZAPP9001” to the view ZFSCM.

 

 

Updating the underlying database tables for the custom fields when the BP transaction is saved

We will need to create FMs and configure the FMs to trigger under specific SAP events.

 

The list of the events can be found from the transaction BUPT using the path:

SAP Menu -> Business Partner -> Control Data -> Events -> Business Data Toolset (BUS7)

 

 

 

In the e.g. described above, 2 FMs were created under the Function Group ‘ZGM_FSCM’.

 

These FMs were:

 

1) FM ‘ZZAPP_BUPA_EVNT_XCHNG’:

The custom FM was attached to the event the event ‘XCHNG’ (which is triggered to check whether Data Has Been changed). The application name used was ‘ZAPP’.

 

2) FM ‘ZZAPP_BUPA_EVNT_DSAVE’:

The custom FM was attached to the event ‘DSAVE’ (which is triggered to Save Data in Database (from Local Memory)). The application name used was ‘ZAPP’.

Eitan Rosenberg

SDB_ADBC - the program

Posted by Eitan Rosenberg Dec 26, 2013

Hi all,

 

As I wrote here http://scn.sap.com/community/abap/blog/2013/12/23/sdbadbc--power-to-the-people

I have been playing with package SDB_ADBC and its gang members....

 

Based on what I learned from program ADBC_QUERY I wrote a program (Y_R_EITAN_TEST_28_01) that I hope you will find it useful .

 

The program allow the user (A programmer) to query data using the raw native power of the local database.


For example In case of Oracle you can refer to Oracle documentation (http://docs.oracle.com/cd/B19306_01/server.102/b14200/toc.htm).

 

- The program create SQL statment based on the selected fields and functions (FORM get_statment) .
- The program create a dynamic table based on the selected fields and functions (FORM run_statment) .
- Using SDB_ADBC clases the program query the data and fill the dynamic table (FORM run_statment).
- The table is presented using CL_SALV_TABLE .

 

The native SQL is not client dependent so using MANDT in the where clue is required.

 

Limitation:
  The program is not design for joins (This require more development and I do not have the time...)
 
Some screens:

 

capture_20131226_120644.png

 

capture_20131226_115955.png

 

Source:

 

Y_R_EITAN_TEST_28_01.txt - the program.

Y_R_EITAN_TEST_28_01_screen_100.txt - screen source .(it is very simple since I use OO components )

 

 

capture_20131226_123501.png

 

capture_20131226_123526.png

 

STATUS_COMMON

 

Define BACK , EXIT and CANCEL as Exit Command.

 

capture_20131226_124042.png

capture_20131226_123820.png

 

TITLE_COMMON

capture_20131226_124300.png

That is all for now .

 

Have fun.

 

Update 2013/12/29

 

I added multi function support.(More power to the peoples...)

See screen cap:

 

Capture.PNG

 

Update 2014/01/01

 

Since I hate typing I just added the SUM function as a check box.

 

Also I forgot to mention that a click on the field name will append the field name to the text box (As I said I hate typing... )

 

Capture_02.GIF

 

Update: 19/02/2014

 

Take into account those pesky "name space" fields.

Its a year of BDC for me....

 

this is my first Blog ..

 

In this Blog i'm sharing how to create Recipe using BDC and  issues which I faced while creating BDC for Recipe Creation C201.

 

Before recipe creation we need to know about BOM and its creation

 

In my previous Document I have explained in detail about BOM and its creation

 

 

 

Recipe Creation



Definition :



Recipe is nothing but planning of manufacturing of products and Recipe is a collection resources .



Recipe is a collection of resources with well planned for manufacturing a product .

 

Recipe is basis for Product costing as well as reference for Process Orders.

 

Recipe will be created for a material and Plant for which BOM already created , moreover BOM is like reference for Recipe

 

Initial Screen

1.png

 

Parts of Recipe :

 

1.Recipe Group

 

It is unique Key to identify Recipe Group .

 

2.Recipe

 

It is a key to differentiate Recipe among Master recipe Group.

 

3.Material and Plant

 

Material and Plant are the reference for Recipe Creation .

 

4. Production Version

 

It is a relation between BOM Header and Recipe based on Alt BOM used .

 

Production version is is used to define different methods of Production through which a material can be produced.


Second Screen : Recipe Header


2.png


5. Status :

 

Status is used to identify the processing status of Recipe .

 

3.png

 

In general Released status is preferred for Task list status.

 

For Cost BOM , status 3 is preferred.

 

6. Usage 

 

Usage is used to indicate for what purpose recipe is used, for ex like recipe used for production or review ..,

 

Usage values are Organisation dependent .

 

7.Planner Group

 

Planner Group is used for Recipe maintenance .

 

Planner Group values are changed as per Organisation Requirement .

 

Third Screen : Operations

 

2.png

 

Standard Values

 

Standard values are used in customization of work center

 

3.png

 

8.Operation/Activity Number

 

It is key which identifies the sequence of operations .

 

In general the Operations are in sequence of 0010,0020...,

 

9.Phase Indicator /SUB Operation/Destination

 

In order to maintain relation between Operations we need to create SUB Operations .

 

Three values need to provided to create sub operations :

 

a.Phase Indicator

b.Sub Operation

c. Destination

 

a.Phase indicator


It is a checkbox , which  is used to indicate whether the operation is sub operation or not .

 

b.Sub Operation :

 

It is used to define for which Operation Sub Operation need to be Assigned .

 

2.png

In the above example , 0010 is Operation and 0020 is sub operation .

 

c.Destination

 

Destination is used to identify Recipe Destination with in plant

 

10.Resource

 

It is the center of recipe creation and it is a key to identify resource in a plant.

 

11.control Key

 

It is use to define which transactions should be executed for Recipe like scheduling or costing ..,

 

 

Create Relationship between Operations

 

To create relation between operations No. of Operations Should be Atleast 4 .

 

 

How to create ?

select all Operations by clicking on select all Button 2.png

 

then click on Generate Relation Button at the bottom 2.png to generate relations

 

 

 

Fourth Screen : Materials

 

before entering 4th Screen we need to create Production version and assign Alt BOM to Production Version .

 

On click of Materials Tab new  popup will appear with Production version as shown below :

 

 

2.png

 

  • In the above screen Mandatory fields are Production version Number , Alt BOM and BOM usage .
  • Here Alt BOM plays key role to link Recipe with BOM .
  • Production version number should be in sequence like 0001,0002....
  • After assigning necessary values , Press check button to activate Production Version, then click on back and close the pop up .

 

5.png


 

Assign Phases to BOM Items

 

Based on the requirement assign Phases created in Operation Tab to Particular BOM Items by selecting  Materials and by clicking on the create assignment  button at the Bottom .

 

A new POP up will appear to assign Phases as shown below :

 

5.png

 

After assigning phases to the necessary BOM Components as below , save the recipe which will create recipe .

 

 

2.png

 

In the above screen if we click on BOM Icon , it will enroute to BOM details .

 

 

BDC for Recipe Creation


Let me introduce the major Issues which i have faced with creating BDC for Recipe Creation

 

1. Page Down Issue

 

2. Selection and deselection of Operations

 

BDC code for Recipe Creation Tcode - C201

 

The Major problem which I faced while creating recipe with more than 10 records is Page Down error .

 

what is Page Down Error ?

 

After entering in to second page or more than that suddenly cursor moves to fist page while filling details in second page .

 

when it occurs ?

 

This Issue I faced at two places

 

1. after entering Standard values (1st standard value, 2nd standard value ...)

2.After entering Charge Qty in standard values  screen .

 

 

what is charge Qty , when it is calculated ?

 

  Charge Qty is division of base Qty by operation Qty and it is calculated for Resources with different UOM from Base UOM.

 

3.png


In the current scenario by default system allowing to enter 10 records w/o page down , for morethan 10 records I have decided Divided entire BDC program of recipe creation into 3 sections :


1. Enter all the Resources

2.Assign Standard values if entered  for the Resources

3.Assign Classification Class and Additional resources.

 

What is Classification class ?

 

According to the Requirement we can assign differentiate similar group of recipe's based on Classification class.

 

How to assign Classification class to particular Operation ?

 

step1 : select created operation

step 2 : Click on resource selection criteria as shown below

 

3.png

 

step3 : fill the classification filed with necessary class name and assign the class

 

 

3.png

 

Assign Additional resources :

 

Additional resc. are nothing but Recipe-specific values are assigned  to the characteristics of this class.


After entering classification class , Additional resources Tab will be enabled as shown below.

 

4.png

 

Solution

 

So finally I divided my entire BDC programming into 3 sections as mentioned above

 

sample Scenario :

 

Create Recipe for material BOM with charge QTy and Additional resources

 

Tcode for Recipe Creation C201 .

 

Step 1: create Recording through SHDB t.code and save it

 

 

step 2 : Create a Report in se38 and define Required declarations

 

Step 3 : replace all the Hard coded values with variables .

 

*---------------------------------------------------------------------------------------------*

*                         BDC for Recipe Creation                                                   *

*---------------------------------------------------------------------------------------------*

 

  DATA : lv_matnr TYPE rc27m-matnr,
lv_stlal
TYPE mast-stlal,
lv_verid
TYPE mkal-verid,
lv_phseq
TYPE plpo-phseq,
lv_losbs
TYPE char13,
lv_bstma
TYPE char13,
lv_bstmi
TYPE char13,
gd_msg  
TYPE string,
lv_date 
TYPE rn1datum-datex,
lv_slno 
TYPE zsl_no,
l_msg   
TYPE bapi_msg,

lit_bom_item
TYPE TABLE OF zsbom_items,
wa_bom_item 
TYPE zsbom_items,

lit_mkal
TYPE STANDARD TABLE OF  mkal,
wa_mkal 
TYPE mkal,

lit_plko
TYPE TABLE OF plko,
wa_plko 
TYPE plko,

lit_plpo
TYPE TABLE OF plpo,
wa_plpo
TYPE plpo,

lit_inob
TYPE TABLE OF inob,
wa_inob 
TYPE inob,

lit_ausp
TYPE TABLE OF ausp,
wa_ausp 
TYPE ausp,

lit_return
TYPE TABLE OF bapiret2,
wa_return 
TYPE bapiret2,

lit_hist_msg 
TYPE TABLE OF zthist_msgs,
wa_hist_msg  
TYPE zthist_msgs,

lv_plnnr
TYPE rc271-plnnr,
lv_plnal
TYPE rc271-plnal,
lv_losvn
TYPE rc271-losvn,
lv_stlan
TYPE mast-stlan,
lv_len  
TYPE i,
lv_lines
TYPE i,

lv_phassign 
TYPE zsbom_items-zph_assign,
lv_text     
TYPE char40,
lv_maktx    
TYPE maktx,
lv_prod_desc
TYPE maktx,
lv_plnkn    
TYPE plnkn,
lv_objek    
TYPE inob-objek,
lv_cuobj    
TYPE inob-cuobj,


lv_chrg_qty
TYPE string,
lv_temp    
TYPE n,
lv_res
(2)   TYPE n,
lv_pgdwn   
TYPE i,
lv_pgdwn1  
TYPE i,
lv_index   
TYPE i,
lv_index1  
TYPE i,
lv_index2  
TYPE i,
lv_lst_ind
(4TYPE n,
lv_flg
(1)      TYPE c,
lv_ph_sel
(4)   TYPE n,

lit_recipe_head_rep
TYPE TABLE OF ztrecipe_h_rep,
wa_recipe_head_rep 
TYPE ztrecipe_h_rep,
wa_recipe_head_rep1
TYPE ztrecipe_h_rep,

lit_recipe_itm_rep 
TYPE TABLE OF ztrecipe_i_rep,
wa_recipe_itm_rep  
TYPE ztrecipe_i_rep,
wa_recipe_itm_rep1 
TYPE ztrecipe_i_rep,


gd_num        
TYPE i,             "operation tab
gd_num1       
TYPE i,
gd_num2       
TYPE i,
gd_cnt
(2)      TYPE c,
gd_cnt1
(2)     TYPE c,
gd_arbpl
(25)   TYPE c,
gd_ltxa1
(25)   TYPE c,
gd_phflg
(25)   TYPE c,
gd_pvznr
(25)   TYPE c,
gd_phseq
(25)   TYPE c,
gd_steus
(25)   TYPE c,
gd_ltxa1_p
(25) TYPE c,
gd_vgw01
(25)   TYPE c,
gd_vgw02
(25)   TYPE c,
gd_vgw03
(25)   TYPE c,
gd_vgw04
(25)   TYPE c,
gd_vgw05
(25)   TYPE c,
gd_vgw06
(25)   TYPE c,
gd_vge06
(25)   TYPE c,
gd_vornr
(25)   TYPE c,
gd_flg
(25)     TYPE c,
gd_bsmch
(25)   TYPE c,
gd_qty_tmp
(14) TYPE c,
gd_atwrt
(25)   TYPE c,
gd_meinh
(25)   TYPE c,
gd_vge
(25)     TYPE c,
gd_chrg_qty   
TYPE string,

lr_bom
TYPE REF TO zcl_bom.

DATAld_num       TYPE i,
ld_num1     
TYPE i,
ld_tmp1
(25TYPE c,
ld_cnt
(2)    TYPE c,
ld_idnrk
(25) TYPE c,
ld_vornr
(25) TYPE c,
ld_flg
(25)   TYPE c,
ld_cnt1
(4)   TYPE n,
ld_cnt2
(4)    TYPE n,
ld_cnt3
(4)   TYPE n,
ld_cnt4
(4)   TYPE n,
lv_tabix    
TYPE i,
lv_count
(4TYPE n,
ld_tmp_m    
TYPE i,
ld_tmp_n    
TYPE i.


TYPES : BEGIN OF ty_class,
atinn
TYPE cabn-atinn,
END OF ty_class.

DATA : wa_class TYPE rmslv_char_class.



*-->Processing


lr_bom
= zcl_bom=>get_instance( ).


*------------------------------------------------------*
*                 CONVERSIONS                       *
*------------------------------------------------------*
CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
EXPORTING
datin 
= sy-datum
format = 'DD.MM.YYYY'
IMPORTING
datex 
= lv_date.

lv_matnr 
= im_recipe_h-matnr.
lv_verid 
= im_recipe_h-verid.   "verid


CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'   "Convert Material
EXPORTING
input  = lv_matnr
IMPORTING
output = lv_matnr
.


*-->get corresponding data

MOVE-CORRESPONDING im_recipe_h TO wa_recipe_h.

*-->get material description

SELECT SINGLE maktx FROM makt INTO wa_recipe_h-maktx WHERE matnr = lv_matnr
.

lv_werks = wa_recipe_h-werks.
lv_prof 
= wa_recipe_h-profidnetz. "pi01
lv_stat 
= wa_recipe_h-statu." wa_recipe_h-statu.
lv_verwe
= wa_recipe_h-verwe."wa_recipe_h-verwe.
lv_vagrp
= wa_recipe_h-vagrp.
lv_bmsch
= wa_recipe_h-bmsch.
lv_ktext
= wa_recipe_h-ktext.
lv_plnme
= wa_recipe_h-plnme.
lv_meinh
= wa_recipe_h-meinh.
lv_maktx
= wa_recipe_h-maktx.
lv_losbs
= zif_d_constant=>c_losbs"to lot size
lv_losvn
= zif_d_constant=>c_losvn.
lv_phseq
= zif_d_constant=>c_phseq.

IF wa_recipe_h-werks CP '10*' .
lv_prod_desc
= wa_recipe_h-maktx.
ELSEIF wa_recipe_h-werks CP '20*'.
lv_prod_desc
= wa_recipe_h-mpr_num.
ENDIF
.

CLEAR wa_ctu_options.
wa_ctu_options
-dismode = 'N'.
wa_ctu_options
-updmode = 'S'.
wa_ctu_options
-defsize = 'X'
.


*-------------------------------------------------------------*
*      FROM LOT SIZE AND TO LOT SIZE           *
*-------------------------------------------------------------*

IF im_recipe_h-werks CP '10*'.

lv_bstmi
= im_recipe_h-bmsch"base quantity
lv_bstma
= im_recipe_h-bmsch.
CONDENSE lv_bstma.
CONDENSE lv_bstmi.
ELSE
.


lv_bstmi
= '1'.
lv_bstma
= zif_d_constant=>c_bstma.
CONDENSE lv_bstma.
CONDENSE lv_bstmi.
ENDIF
.
*----------------------------------------------*
*                VALIDATIONS                *
*----------------------------------------------*


*-->Validate Material number AND Get Alt BOM

SELECT  matnr
werks
stlan
stlal
stlnr
FROM mast
INTO TABLE lit_mast
WHERE matnr = lv_matnr AND werks = lv_werks.

SORT lit_mast[] BY stlal DESCENDING.

READ TABLE lit_mast INTO wa_mast INDEX 1.
CLEAR lv_stlal.

IF wa_mast-stlnr IS NOT INITIAL.
lv_stlal
= wa_mast-stlal.
lv_stlan
= wa_mast-stlan.

ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input  = lv_verid
IMPORTING
output = lv_verid.

REFRESH lit_bdcdata.
REFRESH lit_msgtab
.


*&---------------------------------------------------------------------*
*&                     BDC Recording
*&---------------------------------------------------------------------*
*          TCode : C201 - Create Master Recipe
*----------------------------------------------------------------------*

*-->INITIAL SCREEN


PERFORM bdc_dynpro      USING 'SAPLCPDI' '4000'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'RC271-PROFIDNETZ'.
PERFORM bdc_field       USING 'PLKOD-PLNAL'
lv_plnnr
.
PERFORM bdc_field       USING 'PLKOD-PLNAL'
lv_plnal
.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=TON'.
PERFORM bdc_field       USING 'PLKOD-PLNAL'
' '."lv_plnnr'.
PERFORM bdc_field       USING 'PLKOD-PLNAL'
' '. "lv_plnal.
PERFORM bdc_field       USING 'RC27M-MATNR'
lv_matnr
.
PERFORM bdc_field       USING 'RC27M-WERKS'
lv_werks
.
PERFORM bdc_field       USING 'RC271-PROFIDNETZ'
'PI01'.
PERFORM bdc_field       USING 'RC271-STTAG'
lv_date
.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=TON'.

*-->SECOND SCREEN : Recipe Header


PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field       USING 'PLKOD-PLNAL'
' '.
PERFORM bdc_field       USING 'PLKOD-KTEXT'
wa_recipe_h
-maktx.
PERFORM bdc_field       USING 'PLKOD-WERKS'
lv_werks
.
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLKOD-VAGRP'.
PERFORM bdc_field       USING 'PLKOD-STATU'
lv_stat
.
PERFORM bdc_field       USING 'PLKOD-VERWE'
lv_verwe
.
PERFORM bdc_field       USING 'PLKOD-VAGRP'
lv_vagrp
.
CONDENSE lv_losbs.
PERFORM bdc_field       USING 'PLKOD-LOSBS'
lv_losbs
.
PERFORM bdc_field       USING 'PLKOD-LOSVN'
lv_losvn
.
PERFORM bdc_field       USING 'PLKOD-PLNME'
lv_plnme
.
PERFORM bdc_field       USING 'PLKOD-MEINH'
lv_plnme
.

gd_qty_tmp
= lv_bmsch.

CONDENSE gd_qty_tmp.
PERFORM bdc_field       USING 'PLKOD-BMSCH'
gd_qty_tmp
.


*-----------------------------------------------------------*
*-----------------Operation Tab-----------------------*
*-----------------------------------------------------------*

CLEAR : gd_bsmch,
                wa_recipe_i
.

SORT im_recipe_i BY vornr ASCENDING.

DESCRIBE TABLE im_recipe_i LINES gd_opt1.


*---define no of rows for page down in operation tab------*


LOOP AT im_recipe_i INTO wa_recipe_i .

gd_opt1 = sy-tabix.
gd_opt 
= gd_opt + 1 .

IF  sy-tabix > 10 .
IF gd_opt1 MOD 2 = 0.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P+'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.
ELSE.
DO ( gd_opt1 - 1 DIV 10 TIMES .
PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P+'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.
ENDDO.
ENDIF
.


*-->Determine Page Down for Phases Selected.


IF wa_recipe_i-phflg EQ 'X'.

IF ( gd_opt1 MOD 10 ) = 0.
gd_opt
= 02.
ELSE.
gd_opt
= 02.
ENDIF.
ELSE.

IF lv_flg NE 'X'.
gd_opt
= 02.
ELSE.
gd_opt
= gd_opt1 MOD 10.

IF  gd_opt = 1" Incase of First Record of Every Page
gd_opt
= 02.
ENDIF.
ENDIF.
ENDIF.

ENDIF
.

*--End of Page Down Determination


*--Section 1 : Enter all Items

*--> Recipe Items

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
                                                   
'/00'.
CLEAR gd_phflg.


CONCATENATE 'PLPOD-PHFLG(' gd_opt ')' INTO gd_phflg.
CONDENSE gd_phflg.

PERFORM bdc_field       USING    gd_phflg
                                                      wa_recipe_i
-phflg.
CLEAR gd_pvznr.
CONCATENATE 'PLPOD-PVZNR(' gd_opt ')' INTO gd_pvznr.

CONDENSE gd_pvznr.


PERFORM bdc_field    USING gd_pvznr wa_recipe_i-pvznr"Superordinate Operation

CLEAR gd_phseq.
CONCATENATE 'PLPOD-PHSEQ(' gd_opt ')' INTO gd_phseq.
CONDENSE gd_phseq.
PERFORM bdc_field       USING gd_phseq  wa_recipe_i-phseq"Control Recipe Destination

CLEAR gd_vornr.
CONCATENATE 'PLPOD-VORNR(' gd_opt ')' INTO gd_vornr.
CONDENSE gd_vornr.
PERFORM bdc_field       USING gd_vornr  wa_recipe_i-vornr.

CLEAR gd_arbpl.
CONCATENATE 'PLPOD-ARBPL(' gd_opt ')' INTO gd_arbpl.
CONDENSE gd_arbpl.
PERFORM bdc_field       USING gd_arbpl  wa_recipe_i-arbpl.   " Resource

CLEAR gd_steus.
CONCATENATE 'PLPOD-STEUS(' gd_opt ')' INTO gd_steus.
CONDENSE gd_steus.
PERFORM bdc_field       USING gd_steus wa_recipe_i-steus. " Control key

CLEAR gd_ltxa1_p.
CONCATENATE 'PLPOD-LTXA1(' gd_opt ')' INTO gd_ltxa1_p.
CONDENSE gd_ltxa1_p.
PERFORM bdc_field       USING gd_ltxa1_p wa_recipe_i-ltxa1" Operation short text

CONCATENATE 'PLPOD-BMSCH(' gd_opt ')' INTO gd_bsmch.    "Recipe Item  Quantity
CONDENSE gd_bsmch.
CLEAR gd_qty_tmp.
gd_qty_tmp
= wa_recipe_i-bmsch .

CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING  gd_bsmch  gd_qty_tmp.

CLEAR gd_meinh.
CONCATENATE 'PLPOD-MEINH(' gd_opt ')' INTO gd_meinh.    "Item  UOM
CONDENSE gd_meinh.
PERFORM bdc_field       USING 'BDC_CURSOR' gd_meinh.
PERFORM bdc_field       USING  gd_meinh  wa_recipe_i-meinh.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'/00'.


*------------------------------------------------------------------------*
**    Get Standard value key based on resource                    *
*    - Determine no of standard key values to be enabled       *
*------------------------------------------------------------------------*

IF wa_recipe_i-phflg = 'X'.

DATA : lit_crhd TYPE TABLE OF crhd,
wa_crhd 
TYPE crhd.

SELECT SINGLE *
FROM crhd INTO wa_crhd WHERE arbpl = wa_recipe_i-arbpl
AND  werks = im_recipe_h-werks.

IF wa_recipe_i-vgw01 IS NOT INITIAL.

CLEAR gd_vgw01.
CONCATENATE 'PLPOD-VGW01(' gd_opt ')' INTO gd_vgw01.
CONDENSE gd_vgw01.
CLEAR gd_qty_tmp.
gd_qty_tmp
= wa_recipe_i-vgw01.

PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vgw01
.
PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'
'1'.
gd_qty_tmp
= wa_recipe_i-vgw01.
CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING  gd_vgw01
gd_qty_tmp
.

CLEAR gd_qty_tmp.

"Standard Key UOM
IF wa_crhd-vge01 IS NOT INITIAL.
CLEAR gd_vge.
CONCATENATE 'PLPOD-VGE01(' gd_opt ')' INTO gd_vge.
PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vge
.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
input    = wa_crhd-vge01
language = sy-langu
IMPORTING
output   = wa_crhd-vge01.


PERFORM bdc_field       USING  gd_vge
wa_crhd
-vge01.
ENDIF.

ENDIF.

IF wa_recipe_i-vgw02 IS NOT INITIAL.
CLEAR gd_vgw02.
CONCATENATE 'PLPOD-VGW02(' gd_opt ')' INTO gd_vgw02.
CONDENSE gd_vgw02.
CLEAR gd_qty_tmp.
gd_qty_tmp
= wa_recipe_i-vgw02.
CONDENSE gd_qty_tmp.


PERFORM bdc_field       USING gd_vgw02
gd_qty_tmp
.

IF wa_crhd-vge02 IS NOT INITIAL.
CLEAR gd_vge.
CONCATENATE 'PLPOD-VGE02(' gd_opt ')' INTO gd_vge.
PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vge
.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
input    = wa_crhd-vge02
language = sy-langu
IMPORTING
output   = wa_crhd-vge02.

PERFORM bdc_field       USING  gd_vge
wa_crhd
-vge02.
ENDIF.
ENDIF.

IF wa_recipe_i-vgw03 IS NOT INITIAL.
CLEAR gd_vgw03.
CONCATENATE 'PLPOD-VGW03(' gd_opt ')' INTO gd_vgw03.
CONDENSE gd_vgw03.
CLEAR gd_qty_tmp.
gd_qty_tmp
= wa_recipe_i-vgw03.
CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING  gd_vgw03
gd_qty_tmp
.

IF wa_crhd-vge03 IS NOT INITIAL.
CLEAR gd_vge.
CONCATENATE 'PLPOD-VGE03(' gd_opt ')' INTO gd_vge.
PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vge
.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
input    = wa_crhd-vge03
language = sy-langu
IMPORTING
output   = wa_crhd-vge03.


PERFORM bdc_field       USING  gd_vge
wa_crhd
-vge03.
ENDIF.
ENDIF.

IF wa_recipe_i-vgw04 IS NOT INITIAL.
CLEAR gd_vgw04.
CONCATENATE 'PLPOD-VGW04(' gd_opt ')' INTO gd_vgw04.
CONDENSE gd_vgw04.
CLEAR gd_qty_tmp.
gd_qty_tmp
= wa_recipe_i-vgw04.
CONDENSE gd_qty_tmp.


PERFORM bdc_field       USING gd_vgw04
gd_qty_tmp
.

"Standard Key UOM
IF wa_crhd IS NOT INITIAL.
CLEAR gd_vge.
CONCATENATE 'PLPOD-VGE04(' gd_opt ')' INTO gd_vge.
PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vge
.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
input    = wa_crhd-vge04
language = sy-langu
IMPORTING
output   = wa_crhd-vge04.


PERFORM bdc_field       USING  gd_vge
wa_crhd
-vge04.
ENDIF.
ENDIF.


IF wa_recipe_i-vgw05 IS NOT INITIAL.
CLEAR gd_vgw05.
CONCATENATE 'PLPOD-VGW05(' gd_opt ')' INTO gd_vgw05.
CONDENSE gd_vgw05.
CLEAR gd_qty_tmp.
gd_qty_tmp
= wa_recipe_i-vgw05.
CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING gd_vgw05
gd_qty_tmp
.

"Standard Key UOM


IF wa_crhd-vge05 IS NOT INITIAL.
CLEAR gd_vge.
CONCATENATE 'PLPOD-VGE05(' gd_opt ')' INTO gd_vge.
PERFORM bdc_field       USING 'BDC_CURSOR'
                                                     gd_vge
.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
input    = wa_crhd-vge05
language = sy-langu
IMPORTING
output   = wa_crhd-vge05.


PERFORM bdc_field       USING  gd_vge
                                                    wa_crhd
-vge05.
ENDIF.
ENDIF.

IF wa_recipe_i-vgw06 IS NOT INITIAL.
CLEAR gd_vgw06.
CONCATENATE 'PLPOD-VGW06(' gd_opt ')' INTO gd_vgw06.
CONDENSE gd_vgw06.
CLEAR gd_qty_tmp.
gd_qty_tmp
= wa_recipe_i-vgw06.
CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING gd_vgw06
gd_qty_tmp
.

"Standard Key UOM
CLEAR gd_vge.
CONCATENATE 'PLPOD-VGE06(' gd_opt ')' INTO gd_vge.
PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vge
.

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
input    = wa_crhd-vge06
language = sy-langu
IMPORTING
output   = wa_crhd-vge06.

IF wa_crhd-vge06 IS INITIAL .
wa_crhd
-vge06 = 'H'.                     "Maintained if all Stnd keys are there 6th UOM is not filling
PERFORM bdc_field       USING  gd_vge
wa_crhd
-vge06.
ENDIF.
ENDIF.

IF gd_opt1 > 10 .
IF wa_recipe_i-vgw01 IS NOT INITIAL OR
wa_recipe_i
-vgw02 IS NOT INITIAL OR
wa_recipe_i
-vgw03 IS NOT INITIAL OR
wa_recipe_i
-vgw04 IS NOT INITIAL OR
wa_recipe_i
-vgw05 IS NOT INITIAL OR
wa_recipe_i
-vgw06 IS NOT INITIAL  .

lv_flg
= 'X'.

ELSE.

lv_flg
= ' '.

ENDIF" Set Flag Wether Standard Keys entered or Not
ENDIF.
ENDIF.

CLEAR : lv_index, wa_recipe_i.
ENDLOOP.

*---END OF SECTION 1-----------*


*--SECTION 2 : Charge Qty calculation

 

*----------------------------------------------------------------------*
**       Charge QTY Formula - Only for 20*(FTO) Plants  *
*----------------------------------------------------------------------*


IF im_recipe_h-werks CP '20*'.

CLEAR : gd_opt,
gd_opt1
,
ld_tmp_n
.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.

DESCRIBE TABLE im_recipe_i LINES lv_lines.

*-->Page UP

DO ( lv_lines  DIV 10 + 1 ) TIMES  .
PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P-'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.
ENDDO.

LOOP AT im_recipe_i INTO wa_recipe_i.
ld_cnt1 
= ld_cnt1 + 1.
gd_opt1
= sy-tabix.

IF im_recipe_h-plnme NE wa_recipe_i-meinh AND im_recipe_h-werks CP '20*'.

lv_lst_ind
= gd_opt1.

ld_num  
= ld_cnt1 MOD 11.
ld_num1 
= ld_cnt1 MOD 10.

lv_count
= lv_lines - sy-tabix .

IF gd_opt1 > 10.   "If No of records > 10

IF gd_opt1 MOD 10 NE 0.
IF ld_tmp_n < ( gd_opt1 DIV 10 ) .
CLEAR ld_tmp_n.
ENDIF.
ENDIF.

*-->Determine Page Down
*    If No of Records EQ multiple of 10 then decrease no of records by 1.

IF ( gd_opt1 MOD 10 ) = 0.
lv_pgdwn
= ( gd_opt1 DIV 10 ) - 1.
ELSE.
lv_pgdwn
= ( gd_opt1 DIV 10 ) .
ENDIF .

*-->Get the Previous Record Page Number

IF ld_cnt3 > 10 .
IF ld_cnt3 MOD 10 = 0.
lv_index1
= ld_cnt3 DIV 10 .
ELSE.
lv_index1
= ld_cnt3 DIV 10 + 1.   "Get Page Number of Previous Rec
ENDIF.
ELSE.
lv_index1
= 1.
ENDIF.

DO lv_pgdwn  TIMES .

lv_index1
= lv_index1 - 1.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P+'.                     "1.Page Down

IF  lv_index1 = 0.
IF ld_cnt2 IS NOT INITIAL AND ld_tmp_n IS INITIAL.

IF ld_cnt3 IS NOT INITIAL .
IF ld_cnt3 MOD 10 = 0.
ld_cnt3
= 10.
ELSE.
ld_cnt3
= ld_cnt3 MOD 10.
ENDIF.          "Getting Exact Previous Record Index

CLEAR gd_flg.

CONCATENATE 'RC27X-FLG_SEL(' ld_cnt3 ')' INTO gd_flg.

PERFORM bdc_field  USING gd_flg
' '.                           "2.Deselect Previous Page Record
CLEAR gd_flg.

CLEAR gd_vornr.

ENDIF.

CONCATENATE 'PLPOD-VORNR(' ld_cnt3 ')' INTO gd_vornr.
CONDENSE gd_vornr.

PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vornr
.                   "3.Place the Cursor
CLEAR gd_vornr.
CLEAR ld_cnt2.

IF gd_opt1 DIV 10 EQ 0.
ld_tmp_n
= gd_opt1 DIV 10 - 1.
ELSE.
ld_tmp_n
= gd_opt1 DIV 10.
ENDIF.

ENDIF.   "Index Comparision
ELSE.

PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)' .
ENDIF.
ENDDO.

*          CLEAR : lv_index, lv_index1.

IF lv_count >= 10 AND ld_num1 = 1. "Get the Exact Number for selcting in the 10 rows
ld_cnt1
= 0001.
ELSE.
ld_cnt1
gd_opt1 MOD 10 .    "If the Records is less than 10
IF ld_cnt1 = 0.
ld_cnt1
= 10.
ENDIF.
ENDIF.

lv_index
= gd_opt1"Get Last Page Record  Number.
ENDIF.

*-->Charge Qty Formula

lv_chrg_qty
= im_recipe_h-bmsch / wa_recipe_i-bmsch"Charge Qty Formula
SPLIT lv_chrg_qty AT '.' INTO lv_chrg_qty lv_temp.
lv_temp
= lv_temp+0(1).

IF lv_temp GE 5.
lv_chrg_qty
= lv_chrg_qty + 1.
ENDIF.

IF lv_chrg_qty EQ '0'.
lv_chrg_qty
= 1.
ENDIF.

gd_chrg_qty
= lv_chrg_qty.
CONDENSE gd_chrg_qty.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=PICK'.
CLEAR gd_vornr.
CONCATENATE 'PLPOD-VORNR(' ld_cnt1 ')' INTO gd_vornr.
CONDENSE gd_vornr.

PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vornr
.
IF ld_cnt2 IS NOT INITIAL.
CLEAR gd_flg.
CONCATENATE 'RC27X-FLG_SEL(' ld_cnt2 ')' INTO gd_flg.

ENDIF.

PERFORM bdc_field       USING gd_flg
' '.
PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'
'1'.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0120'.     "Charge QTY
PERFORM bdc_field       USING 'BDC_OKCODE'
'/00'.

PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-UMREZ'.
PERFORM bdc_field       USING 'PLPOD-UMREZ'
gd_chrg_qty
.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0120'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=BACK'.

ld_cnt2
= ld_cnt1.   "previous Item to unselect
ld_cnt3
= gd_opt1.
CLEAR gd_chrg_qty.
ENDIF. "End of UOM Check
CLEAR wa_recipe_i.
ENDLOOP.

ENDIF.    "End of Charge QTy


SECTION 3 : Classificaion Class


*------------------------------------------------------------------------------------------------------*
*    ASSIGN CLASSIFICATION CLASS AND ALTERNATE RESOURCES
*  -  FOR FOR PARTICULAR RESOURCE AND ONLY FOR 2003 PLANT       *
*-------------------------------------------------------------------------------------------------------*

IF im_recipe_h-werks EQ '2003'.

CLEAR : gd_opt,
gd_opt1
,
lv_tabix
,
ld_cnt1
,
ld_num1
,
ld_cnt2
,
ld_cnt3
,
ld_tmp_n
,
lv_pgdwn
,
lv_index
.

DO  lv_lines  DIV 10 TIMES .
PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P-'.

PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.
ENDDO.

*-->Deselct the selected last record in Charge Qty and Once Page Up to First Record
IF lv_lst_ind IS NOT INITIAL.
IF lv_lst_ind > 10.

*-->Goto Exact record where the Record is selected

IF ( lv_lst_ind MOD 10 ) = 0.
lv_pgdwn1
= ( lv_lst_ind DIV 10 ) - 1.
ELSE.
lv_pgdwn1
= ( lv_lst_ind DIV 10 ).
ENDIF .

IF lv_lst_ind MOD 10 = 0.
lv_lst_ind
= 10.
ELSE.
lv_lst_ind
= lv_lst_ind MOD 10.
ENDIF.

DO lv_pgdwn1 TIMES .   "Goto Exact Record
PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P+'.
ENDDO.

DO  lv_pgdwn1 TIMES .
PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P-'.

CONCATENATE 'RC27X-FLG_SEL(' lv_lst_ind ')' INTO gd_flg.

PERFORM bdc_field  USING gd_flg
' '.
CLEAR gd_flg.

CLEAR gd_vornr.
CONCATENATE 'PLPOD-VORNR(' lv_lst_ind ')' INTO gd_vornr.
CONDENSE gd_vornr.

PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vornr
.
CLEAR gd_vornr.

ENDDO.
CLEAR lv_lst_ind.

ELSE.
PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P-'.
CONCATENATE 'RC27X-FLG_SEL(' lv_lst_ind ')' INTO gd_flg.

PERFORM bdc_field  USING gd_flg
' '.
CLEAR gd_flg.

CLEAR gd_vornr.
CONCATENATE 'PLPOD-VORNR(' lv_lst_ind ')' INTO gd_vornr.
CONDENSE gd_vornr.

PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vornr
.
CLEAR gd_vornr.

ENDIF.
ENDIF.

*-->End of Page Down for Last selected record in Charge Qty Assignment

LOOP AT im_recipe_i INTO wa_recipe_i .

lv_tabix 
= sy-tabix.
ld_cnt1 
= ld_cnt1 + 1.

IF wa_recipe_i-phflg NE 'X' AND wa_recipe_i-class IS NOT INITIAL .

lv_count
= lv_lines - sy-tabix .

ld_num1 
= ld_cnt1 MOD 11.

IF ld_num1 = 1.
ld_num1
= ld_num1 DIV 10 .
ENDIF.

"Page Down for Records More Than 10 and to deselct the selected Record

IF lv_tabix > 10 .
IF ld_tmp_n < ( lv_tabix DIV 10 ) .
CLEAR ld_tmp_n.
ENDIF.

*-->Determine Page Down for Additional resources

IF ( lv_tabix MOD 10 ) = 0.
lv_pgdwn
= ( lv_tabix DIV 10 ) - 1.
ELSE.
lv_pgdwn
= ( lv_tabix DIV 10 ) .
ENDIF .
**--End of PageDown

*-->Get Page Number and Exact Record Number
IF ld_cnt3 > 10 .
IF ld_cnt3 MOD 10 = 0.
lv_index1
= ld_cnt3 DIV 10 .
ELSE.
lv_index1
= ld_cnt3 DIV 10 + 1.   "Get Page Number of Previous Rec
ENDIF.
ELSE.
lv_index1
= 1.
ENDIF.

DO lv_pgdwn TIMES .

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P+'.
lv_index1
= lv_index1 - 1.

IF lv_index1 = 0.
IF ld_cnt2 IS NOT INITIAL AND ld_tmp_n IS INITIAL.

**--Get the Exact Previous Record
IF ld_cnt3 IS NOT INITIAL .
IF ld_cnt3 MOD 10 = 0.
ld_cnt3
= 10.
ELSE.
ld_cnt3
= ld_cnt3 MOD 10.
ENDIF.          "Getting Exact Previous Record Index
ENDIF.

CLEAR gd_flg.
CONCATENATE 'RC27X-FLG_SEL(' ld_cnt3 ')' INTO gd_flg.

PERFORM bdc_field  USING gd_flg
' '.
CLEAR gd_vornr.
CONCATENATE 'PLPOD-VORNR(' ld_cnt3 ')' INTO gd_vornr.
CONDENSE gd_vornr.

PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vornr
.
CLEAR gd_vornr.
CLEAR ld_cnt2.

IF lv_tabix  MOD 10 EQ 0.
ld_tmp_n
= lv_tabix DIV 10 - 1.
ELSE.
ld_tmp_n
= lv_tabix DIV 10.
ENDIF.

ENDIF.
ELSE.
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.
ENDIF.
ENDDO.

IF lv_count >= 10 AND ld_num1 = 0 .
ld_cnt1
= 0001.
ELSE.
ld_cnt1
= lv_tabix MOD 10 .    "If the Records is less than 10
IF ld_cnt1 = 0.
ld_cnt1
= 10.
ENDIF.
ENDIF.
ENDIF.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'/00'.

CLEAR gd_arbpl.
CONCATENATE 'PLPOD-ARBPL(' ld_cnt1 ')' INTO gd_arbpl.
CONDENSE gd_arbpl.
PERFORM bdc_field       USING 'BDC_CURSOR'
gd_arbpl
.

PERFORM bdc_field       USING gd_arbpl
wa_recipe_i
-arbpl.
CLEAR gd_arbpl.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=OPCA'.
CLEAR gd_vornr.

CONCATENATE 'PLPOD-VORNR(' ld_cnt1 ')' INTO gd_vornr.

PERFORM bdc_field       USING 'BDC_CURSOR'
gd_vornr
.
PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'
'1'.
IF ld_cnt2 IS NOT INITIAL.
CLEAR gd_phflg.
CONCATENATE 'RC27X-FLG_SEL(' ld_cnt2 ')' INTO gd_phflg.
PERFORM bdc_field       USING gd_phflg
' '.
ENDIF.

CLEAR gd_phflg.
CONCATENATE 'RC27X-FLG_SEL(' ld_cnt1 ')' INTO gd_phflg.
PERFORM bdc_field       USING gd_phflg
'X'.
ld_cnt2
= ld_cnt1"for Deselecting the same record

*-->Assign CLassification Class type 019

PERFORM bdc_dynpro      USING 'SAPLCLCA' '0602'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'RMCLF-KLART'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field       USING 'RMCLF-KLART'
zif_d_constant
=>c_klart.

*-->assign Classification CLass

PERFORM bdc_dynpro      USING 'SAPLCLFM' '0500'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'RMCLF-CLASS(01)'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field       USING 'RMCLF-CLASS(01)'
wa_recipe_i
-class.

*-->Assign Additional Resource to Classification class
CLEAR gd_opt1.

SELECT SINGLE * FROM rmslv_char_class INTO CORRESPONDING FIELDS OF wa_class WHERE class = wa_recipe_i-class.

PERFORM bdc_dynpro      USING 'SAPLCTMS' '0109'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'RCTMS-MWERT(01)'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=BACK'.

IF wa_recipe_i-atwrt1 IS NOT INITIAL.
gd_opt1
= gd_opt1 + 1.

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MNAME(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_class
-atnam.        "CLass Name

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MWERT(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_recipe_i
-atwrt1"Additional Resource
ENDIF.

IF wa_recipe_i-atwrt2 IS NOT INITIAL.
gd_opt1
= gd_opt1 + 1.


CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MNAME(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_class
-atnam.        "CLass Name

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MWERT(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_recipe_i
-atwrt2.
ENDIF.


IF wa_recipe_i-atwrt3 IS NOT INITIAL.
gd_opt1
= gd_opt1 + 1.

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MNAME(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_class
-atnam.        "CLass Name

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MWERT(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_recipe_i
-atwrt3.
ENDIF.

IF wa_recipe_i-atwrt4 IS NOT INITIAL.
gd_opt1
= gd_opt1 + 1.

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MNAME(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_class
-atnam.        "CLass Name

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MWERT(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_recipe_i
-atwrt4.
ENDIF.

IF wa_recipe_i-atwrt5 IS NOT INITIAL.

gd_opt1
= gd_opt1 + 1.

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MNAME(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_class
-atnam.        "CLass Name

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MWERT(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_recipe_i
-atwrt5.

ENDIF.

IF wa_recipe_i-atwrt6 IS NOT INITIAL.
gd_opt1
= gd_opt1 + 1.

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MNAME(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_class
-atnam.        "CLass Name

CLEAR gd_atwrt.
CONCATENATE 'RCTMS-MWERT(' gd_opt1 ')' INTO gd_atwrt.
CONDENSE gd_atwrt.
PERFORM bdc_field      USING gd_atwrt
wa_recipe_i
-atwrt6.

ENDIF.

PERFORM bdc_dynpro      USING 'SAPLCLFM' '0500'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'RMCLF-CLASS(01)'.

PERFORM bdc_field       USING 'BDC_OKCODE'
'=ENDE'.
PERFORM bdc_field       USING 'RMCLF-PAGPOS'
'1'.


PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'/00'.
ld_cnt3
= lv_tabix .
ld_cnt4
= lv_tabix.
ENDIF.
CLEAR gd_opt1.
ENDLOOP.
ENDIF" Additional Resources

CLEAR ld_tmp_n.



*-------------------------------------------------------------------------*
*    GENERATE RELATIONSHIP IF RECIPE ITEMS     *
*  -   >= 4 RECORDS                                                        *
*-------------------------------------------------------------------------*

DESCRIBE TABLE im_recipe_i LINES lv_lines.
IF lv_lines GE 4.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.             "GENERATE RELATIONS
PERFORM bdc_field       USING 'BDC_OKCODE'
'=MAAL'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=AOBC'.                  "All Phases
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.

PERFORM bdc_dynpro      USING 'SAPLCPDI' '1000'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'AUSWAHL_PHASE2'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=OK'.
PERFORM bdc_field       USING 'AUSWAHL_PHASE1'
'X'.
PERFORM bdc_field       USING 'AUSWAHL_PHASE2'
' '.
PERFORM bdc_field       USING 'AUSWAHL_SICHT1'
'X'.
PERFORM bdc_field       USING 'PLAB-AOBAR'
'FS'.

ENDIF.


*------------------------------------------------------------------------*
*    CREATE PRODUCTION VERSION  TAB                *
*------------------------------------------------------------------------*

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=OMBO'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'PLPOD-VORNR(01)'.

PERFORM bdc_dynpro      USING 'SAPLCMFV' '0200'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'MKAL-STLAN'.
PERFORM bdc_field       USING 'MKAL-VERID'
lv_verid
.
PERFORM bdc_field       USING 'MKAL-TEXT1'
lv_prod_desc
.
PERFORM bdc_field       USING 'MKAL-BSTMA'
lv_bstma
.
PERFORM bdc_field       USING 'MKAL-BSTMI'
lv_bstmi
.
PERFORM bdc_field       USING 'MKAL-ADATU'
lv_date
.
PERFORM bdc_field       USING 'MKAL-BDATU'
'31.12.9999'.
PERFORM bdc_field       USING 'MKAL-STLAL'
lv_stlal
.
PERFORM bdc_field       USING 'MKAL-STLAN'
wa_mast
-stlan.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=BACK'.



*----------------------------------------------------------------------------------*
*      GET PHASE TO BE ASSIGNED AND                                 *
*      SELECT BOM COMPONENT AND ASSIGN PHASE         *
*----------------------------------------------------------------------------------*

CALL METHOD lr_bom->zif_d_bom~read
EXPORTING
im_reinr
= wa_recipe_h-reinr
IMPORTING
ex_bom_i
= lit_bom_item.

DATA : lv_phase(4) TYPE c,
lv_lines1
(4) TYPE n,
lv_desc
TYPE string.

DESCRIBE TABLE  lit_bom_item LINES lv_lines1.
CLEAR : ld_cnt1,ld_num,ld_num1,lv_count.
LOOP AT  lit_bom_item INTO wa_bom_item.

*---Split Phase to be assigned to get Exact phase value

SPLIT wa_bom_item-zph_assign AT '-' INTO lv_phase lv_desc.
CONDENSE lv_phase.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input  = lv_phase
IMPORTING
output = lv_phase.


*--Begin of Page Down----------*

ld_cnt1
= ld_cnt1 + 1.
ld_num 
= ld_cnt1 MOD 6.
ld_num1
= ld_cnt1 DIV 6.
lv_count
= lv_lines1 - sy-tabix .

IF ld_cnt1 > 6 AND  ld_num = 1 .                               "Page Down

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=P+'.
CONCATENATE 'STPOB-IDNRK(' '1' ')' INTO ld_idnrk.
PERFORM bdc_field       USING 'BDC_CURSOR' ld_idnrk.

IF lv_count >= 6 .
ld_cnt1
0001 .
ELSE.
ld_cnt1
= ( 6 lv_count ) .   "If the Records are lessthan 6
ENDIF.
ENDIF.


*---End OF Page Down--------------*

PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=ENT1'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=NEW'.

CLEAR ld_idnrk.
CONCATENATE 'STPOB-IDNRK(' ld_cnt1 ')' INTO ld_idnrk.     "CURSOR IDNRK
CONDENSE ld_idnrk.
PERFORM bdc_field       USING 'BDC_CURSOR' ld_idnrk   .


CLEAR ld_flg.
CONCATENATE 'RC27X-FLG_SEL(' ld_cnt1 ')' INTO ld_flg.
CONDENSE ld_flg.
PERFORM bdc_field       USING ld_flg                  "'RC27X-FLG_SEL(01)'
'X'.

PERFORM bdc_dynpro      USING 'SAPLCM01' '5090'.
PERFORM bdc_field       USING 'BDC_CURSOR'
'RCM01-VORNR'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=GOON'.
CONDENSE wa_bom_item-zph_assign.
PERFORM bdc_field       USING 'RCM01-VORNR'
lv_phase
.

PERFORM bdc_field       USING 'BDC_OKCODE'
'=ENT1'.

ENDLOOP.


PERFORM bdc_dynpro      USING 'SAPLC2CU' '0100'.
PERFORM bdc_field       USING 'BDC_OKCODE'
'=BU'.

REFRESH lit_msgtab[].


*------------------------------------------------------------------*
*---Call Transaction C201 - RECIPE CREATION----*
*------------------------------------------------------------------*

CALL TRANSACTION 'C201'  USING  lit_bdcdata
OPTIONS
FROM wa_ctu_options
MESSAGES
INTO lit_msgtab .

IF sy-subrc NE 0.

LOOP AT lit_msgtab INTO wa_msgtab .
*      IF wa_msgtab-msgtyp EQ ''.

CLEAR gd_msg.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id        = wa_msgtab-msgid
lang     
= wa_msgtab-msgspra
no        = wa_msgtab-msgnr
v1       
= wa_msgtab-msgv1
v2       
= wa_msgtab-msgv2
v3       
= wa_msgtab-msgv3
v4       
= wa_msgtab-msgv4
IMPORTING
msg      
= gd_msg
EXCEPTIONS
not_found
= 1
OTHERS    = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

wa_return
-id = wa_msgtab-msgid.
wa_return
-number = wa_msgtab-msgnr.
wa_return
-message = gd_msg.
wa_return
-type = 'E'.
APPEND wa_return TO e_return.

ENDLOOP.
*-----End of BDC for recipe creation -------*

 


Note : we can cross check the create BOM and Recipe using Tcode C223


Queries are mostly used by the functional to generate quick reports without using ABAP code. But the there are certain situations where the report cannot be generated directly through queries using joins. ABAP code comes in to picture in such situations.

 

In some queries we might have to display Quantity, Currency and total price etc., in output report. Then some additional indicator fields to display units are also automatically generated. These fields have to be either populated or have to be hidden in the output. This post deals with hiding such additional indicator fields.

 

In the below picture you can see the additional indicator field of Total Price which is not populated and has to be hidden.

 

First.PNG

 

First go to transaction SQ00 or SQ01. Select the query area (In Environment) either Standard or Global. Give the query name and click on change.

 

In the next screen select Basic List from the application tool bar.

 

Basic List.PNG

 

You will be taken to Query layout design screen. Go to the Data Fields windows in the right and expand the fields. Select you the field for which you want to hide the indicator field. In our case we are selecting Condition Base Value.

 

Data Fields.PNG

 

In the right window all the output fields will be displayed sequentially based on their properties. By clicking on them you will be able to see the field name and its properties in the Quick Viewer window in the left below data field’s window.

 

Selection.PNG

 

The properties of the fields can be defined here. Select the required radio button for the indicator field. Here we are disabling the currency indicator field. Similarly you can set the field position to display to the right or left.

 

Properties.PNG

 

Now activate the query and test it you can see that the field is hidden.

 

Field Diabled.PNG

 

Hope this is helpful.

Recently my colleague Zhang, Harry has introduced one useful tool to me and I would like to share it with you. ABAP static analysis tool SQF is a static code analysis tool developed in package SUPPORT_QUERY_FRAMEWORK in software component SAP_BASIS.

It contains lots of handy tool or short cut to other system utility tools. The most attractive function which is worthy to put it into my toolset is the static code analysis.

1. use tcode SQF, double click on "Source code Analysis"

clipboard1.png

2. Maintain the ABAP object which you would like to do static analysis.

In this example it is function module CRM_PRODUCT_GETLIST2. Specify the object type as well, which could be found in table TADIR.

The Analysis Depth 6 means: for example in the implementation of the FM, it calls another FM or subroutine, these delegated calls will also be analyzedby the tool. Say FM calls A and A calls B, B calls C, C calls D, D calles E, E calls F and F calls G, depth = 6 means any further calls starting from F calls G will be ignored.

clipboard2.png

3. Click save button and it is automatically navigated back to SQF main view. Click F8 to execute.

clipboard3.png

The progress will be displayed in the bottom, the bigger size of depth specified, the more time the analysis will take.

clipboard4.png

After execution, the color of icon changes from white to blue, which means the analysis result is available.

clipboard5.png

4. The analyis results are categorized into four groups:

 

a. Call hierarchy, something like the one in SAT.

clipboard6.png

b. the table read access in static call. Those table read access done via dynamic coding will be listed in group d.

clipboard7.png

Compare with DB access list analyzed by runtime trace SAT, there are far more entries than the static one. This is not surprising, as in CRM product, the set type access is implemented in a highly dynamic way.

dy.png

c. interface call:

clipboard9 (1).png

d. Dynamic coding

clipboard10.png

Hi all,

 

Recently there was some mentions of package SDB_ADBC in passing.

 

Personally I was not aware of its existence so I ask some "older" ABAP programmers
and all I received was was a big null.....

 

package SDB_ADBC deals with native SQL access . Since it is native ALL the power of your local server is accesible.

 

So using program ADBC_QUERY as a guide I created a program that I hope I will be happy to share with you in the near future.

 

Update here it is: SDB_ADBC - the program

 

Note the highlighted yellow text

 

Capture.PNG

This blog explains how to find Text name,Text ID, language and text object from the master data and change it as per our requirement.

 

Finding Text name,Text ID, language and Text object :

 

Let us take an example of a customer from VD03 transaction.

1.JPG

 

Then go to, EXTRAS --> TEXTS.

2.JPG

 

Once the texts appear, double click on the text we want to change. Lets choose "Internal Note" for our case.

3.JPG

Once the "Internal note" is displayed, GOTO --> Header.

4.JPG

 

Now we can see the Text Header, where we can find,Text name,Text ID, language and Text object as below:

5.JPG

 

Changing the TEXTs :

 

We make use of function module "SAVE_TEXT" using Text name,Text ID, language and Text object to change the master data text.

And write a simple report as below:

 

***************************************************************************

REPORT  ZINTERNALNOTE_CHANGE.

 

data:

      lint_header TYPE STANDARD TABLE OF THEAD,

      lws_header TYPE  THEAD,

      lint_lines TYPE STANDARD TABLE OF tline,

      lws_lines TYPE  tline,

      lw_text TYPE thead-tdname.

 

START-OF-SELECTION.

 

lws_header-tdobject = 'KNVV'.                             "text object from above

lws_header-tdname = '0000472421SE100101'.      "text name from above

lws_header-tdid = 'Z008'.                                     "text ID from above

lws_header-tdspras = 'E'.                                    "text language from above

 

  lws_lines-TDFORMAT = '*'.

  lws_lines-TDLINE = 'text'.

 

  APPEND lws_lines to lint_lines.

 

  CALL FUNCTION 'SAVE_TEXT'             

    EXPORTING

      header                = lws_header

    SAVEMODE_DIRECT       = 'X'

    tables

      lines                 = lint_lines .

 

  IF sy-subrc = 0.

      write : 'Internal note text changed'.

  ENDIF.

 

***************************************************************************

 

Once the report is executed, we can see the change reflected as below :

6.JPG

 

Thanks,

Anil Supraj

Created by Venkat Reddy


Sample Scenario - If the date maintained in the vendor master is less than Payment Date then the payments made to that specific Vendor in the F110 run should not get paid.

 

 

Functional Configuration that needs to be done in transaction code - FIBF

Step-1 Product needs to be created.


Step-2 Under Process Module we have to assign the BTE-1830 and function module in which the logic is maintained to restrict the payments.


 

 

Technical Part

SAP Documentation of this function module -


 

 

Copy function module - SAMPLE_PROCESS_00001830 into Z.

Note: 'Z' Function module name should be the same as maintained in the config of process module in FIBF t-code.

Source Code


 

 

Code

* Local vaiable to hold gbdat
data :
lv_gbdat
type lfa1-gbdat.

loop at t_regup.
* Checking gbdat if it is less than payment date
select single gbdat
into lv_gbdat
from lfa1
where lifnr eq t_regup-lifnr.
if sy-subrc eq 0.
if lv_gbdat is not initial.
if lv_gbdat LT t_regup-LAUFD.
t_regup
-XIGNO = 'X'.
modify t_regup INDEX sy-tabix from t_regup transporting XIGNO.
clear: t_regup, lv_gbdat.
endif.
else.
endif.
else.
endif.
endloop.


Testing

For example I have 2 invoices to be paid for the vendors – 100214 and 102165.


 

I have maintained date(GBDAT) in vendor Master for vendor-100214


 

 

 

F110 RUN


 

Proposal Display

As date in LFA1-GBDAT for vendor 100214 is 22.10.2013 which is less than payment date that is 23.10.2013 so the payment for 100214 is stopped.



Proposal Log


 

Payment Advice in SOST

Payment Advice got generated for only right vendor which got paid that is 102165 only.


 

 

FBL1N Vendor 100214 is not paid but vendor 102165 is paid.


 

This explains how to restrict payments to Vendor under certain conditions. Good Luck..!!!

 

Thanks..!!! VEnk@

This is not something new but i got to work on SAP system in my recent assignment where i wanted to access SAP system URL from SAP mobile platform. Here is my finding on this:

 

Prerequisite: You must be having SAP GUI Logon pad.

 

 

Steps:

 

1. Login to desired SAP system with valid credentials

 

2. Run SICF transaction

 

1.PNG

 

3. Execute or press F8

 

 

2.PNG

 

 

4. Expand default_host

 

 

3.PNG

 

 

5. look for ping under sap>bc

 

4.PNG

 

 

6.      Right click > Test Service

 

          Choose Allow this one time from the drop down

 

5.PNG

 

7. It will open in browser, asking for SAP system user id and password

 

6.PNG

 

After giving right credentials, you will see below message

 

7.PNG

 

URL would like below

 

http://localhost:8000/sap/bc/ping?sap-client=800

 

 

I hope this sharing would be helpful. Your comments and suggestions are most welcome.

Hi all,

 

I would like to share with you a some code development .

 

There is a constant request to generate Excel report from SAP .


As far as I know there is no built in support to do that from ABAP.


There is also the requirement to run the whole show in back ground job .

The regular "solution" is create html files, CSV files etc.

 

There is ABAP project http://wiki.scn.sap.com/wiki/display/ABAP/abap2xlsx but not every
organization would like to go this way.


Since I use Java as a hobby I thought I will try and use java to do the job .


The code supplied here is supplied as is. Try it and see if it is good for you.

 

Steps

  • Create XML using ABAP .
    The XML will contain meta data and instructions to the java program.
  • Write the XML to a file .
  • Call Java as external command .
  • The Java program will parse the XML file and generate the Excel file.

 

Open source projects used

Apache POI - http://poi.apache.org/ - the Java API for Microsoft Documents
This is main work horse... it will be used to generate the Excel files .
At the time of writing I did not utilize the full potential of this project. It is full of goodies that
are worth exploring...(I plan to try and use the "Formula Support" ).


Apache Commons CLI - http://commons.apache.org/proper/commons-cli
parsing command line options .

 

Apache Commons Lang - http://commons.apache.org/proper/commons-lang/
StopWatch.


Required jars from the projects (Already included in XmlFileToExcel.jar )

commons-cli-1.2.jar
commons-lang3-3.1.jar
dom4j-1.6.1.jar
poi-3.9-20121203.jar
poi-ooxml-3.9-20121203.jar
poi-ooxml-schemas-3.9-20121203.jar
xmlbeans-2.3.0.jar


The environment
Java Editor - Eclipse -  http://www.eclipse.org/


The Java code is located here: https://drive.google.com/folderview?id=0B6Cb7sgVnODWNV9DS29kQXdPblE&usp=sharing

The reason for putting the code here is because of the file types involved.

(If someone can point me to a place within scn.sap.com I will be grateful...)


XmlFileToExcel.zip - The whole set of source code is in a this zip file this way the directory structure of the Java project is preserved.


XmlFileToExcel.jar - This is the ".exe" equivalent of Java .
                     This file contain all the required jars from the projects .
                     The jar was created by eclipse using the "Runnable JAR File Exporter"
                     Class main.Main is the start class for this program.
                     This file is actually a zip file with extension of "jar".

 

Y_R_EITAN_TEST_40_02.xml  - Sample XML created from SAP .

Y_R_EITAN_TEST_40_02.xlsx - Sample Excel generated by the java program .

            

Java Setup

 

  • Create in some shared folder accessible from sap the following:
    • A folder with the name "jre" this will contain the "Java Runtime Environment".
    • - Install java jre on your PC .
        http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html
      - Note the folder where you install the jre (Usually C:\Program Files\Java\jre7 )
      - Copy folder "jre7" to folder "jre" .
    • Create a batch file named Y_JAVA_1.bat
      The content of the file:(note the "\bin")

      path \\<path to jre>\bin
      java.exe -jar %1 %2 %3 %4 %5 %6 %7 %8 %9
    • Download XmlFileToExcel.jar and put it next to Y_JAVA_1.bat .

The folder will look like this:

capture_20131212_110900.png

 

 

SAP setup (Simple....)

program:( Y_R_EITAN_TEST_40_02 source included)

Upload the source to SAP and activate .


The program use table sbook as input (On our site it contain 100000 records)
The program read the selected records (FORM get_data_1) .
The program generate and write XML file (FORM write_1_to_xml) .
The program Execute an External Command and call java (FORM write_2_to_excel) .

 

 

External command

Use Transaction SM69 and add "Y_JAVA_1" as external command.

Y_JAVA_1 will call the batch file Y_JAVA_1.bat with the required parameters.

 

capture_20131212_094913.png


When you run the program you will be prompted for "My folder" this also needs to be a shared folder accessible from SAP .

 

All the paths needs to to be in \\host\directoryname structure (Universal Naming Convention) .

 

Thats all for now. have fun....

Inspiration

For faster results, we often execute programs in parallel using background jobs. Even though this might be a good idea in terms of processing efficiency, on many occasions this results in high utilization of the system resources and non-availability of background work processes for other key custom operations.

 

Solution

The below technique provides a controlled and conservative approach towards multiple/parallel job generation. With this technique, we can set a maximum utilization percentage and hence always reserve some work processes for other operations. The attributes like utilization threshold and delay can be input as a Parameter/Select-option in the program or can be maintained in selection variable table TVARVC or a custom table, but to keep it simple I am going to use this as constants in the program.

 

The key function that we use in this method is TH_GET_WPINFO which returns the details of the active work processes in the system. The function takes as input 2 optional parameters SRVNAME (Application server) and WITH_CPU. If the job processing has to be limited to a specific server on the system, these parameters can be used to limit the query and later submit the job to the specific server group. But if no restrictions need to be imposed in terms of servers, these can be left blank. The function returns the list of work processes in the system and is similar to SM50 screen (except for the fact that SM50 shows the work processes only from the server on which user is logged on to). Based on this information, we can determine the total and available work processes and the background work process utilization level. Based on the percentage, we can either generate the next job or wait for predefined amount of time and try again.

 

Assumptions

Utilization threshold : 60%

No. of jobs to be executed : 10

Wait before retry if utilization is too high : 10 seconds

 

Source Code

REPORT  zcons_bgd_proc.

 

CONSTANTS:

  "Assuming the utilization limit to be 60%

  c_limit  TYPE p DECIMALS 2 VALUE 60.

 

DATA:

  "Assuming a total of 10 jobs need to be generated

  v_jobs    TYPE i VALUE 10,

  "Assuming a wait time of 10 seconds to be inserted

  " if utilization is above limit

  v_delay   TYPE i VALUE 10.

 

DATA:

  lt_wplist TYPE TABLE OF wpinfo,

  v_total   TYPE i,

  v_utilz   TYPE i,

  v_uperc   TYPE p DECIMALS 2.

 

DO.

  CALL FUNCTION 'TH_GET_WPINFO'

* EXPORTING

*   srvname          =  "Application server optional

*   with_cpu         =  "CPU optional

    TABLES

      wplist           = lt_wplist

   EXCEPTIONS

     send_error       = 1

     OTHERS           = 2.

  IF sy-subrc = 0.

 

    "Retain details of background work processes only

    DELETE lt_wplist WHERE wp_itype NE 4.

    DESCRIBE TABLE lt_wplist LINES v_total.

 

    "Delete the work processes in Waiting state

    DELETE lt_wplist WHERE wp_istatus = 2.

    DESCRIBE TABLE lt_wplist LINES v_utilz.

    v_uperc = v_utilz * 100 / v_total.

 

    "If utilization is within set threshold, proceed

    IF v_uperc LE c_limit.

      "<Generate background job>

      v_jobs = v_jobs - 1.

      IF v_jobs = 0.

        EXIT.

      ENDIF.

 

      " If utilization crosses threshold, wait

    ELSE.

      WAIT UP TO v_delay SECONDS.

    ENDIF.

  ENDIF.

ENDDO.

 

Improvements

Please suggest alternate approaches you have used to handle similar situations at program level.

Do you also keep your ABAP snippets in some kind of ASCII-files using notepad or other editors to look them up? If you want to lookup your ABAP code when you are offline everything is displayed in one color (mainly black).

 

ABAP in eclipse can not be used to display ABAP code offline, because you are not connected to an ABAP project. That is because the pretty printing is done using the ABAP back end. Only in that way ABAP in eclipse is able to keep track of different ABAP versions.

 

 

So I was very happy to find out, that with jEdit - a programmers editor written in java - I can do keyword high lightning as well as folding and indention regarding a statement block.

 

 

Everything is controlled by a so called mode. It is a xml file which tells the editor, which are the keywords and how the folding and indention is done. Nathan Jones started with some small configuration. I added the keywords regarding ABAP 7.31 as well as folding and indention.

 

In the first picture you see a typical jEdit coloring. If you want the ABAP coloring, you have to adjust that manually in the settings, because the color itself can not be controlled by the mode.

 

 

Finally you have to edit the catalog file, which connects the file extension with the mode. I have chosen .abap as well as the ABAP in eclipse extension .asinc. You add your own. The abap.xml file you put in the main directory c:/programs/jedit/modes. There you also find the catalog.xml, which you have to edit.

 

What do you think. Is this useful for you? What are your experience with that solution? Do you know other editors to display/edit ABAP?

The ABAP Class Documentation Generator works equal to the well-known JavaDoc tool for documenting Java classes. It is available in software component BBPCRM (starting with CRM 7.0)

 

A good documentation will
1. make handover more smooth, ease the know-how transfer 
2. help customers e.g. for BAdI implementation reference

 

How to use:

1. Make documentation on class level. You need to create a dummy private instance method with naming convention CLASS_DOCU.Then make all documentations before the first line of that method implementation code.

http://farm6.staticflickr.com/5516/11336530844_488dacc2b7_o.png

 

2. In the method implementation source code, just make comments the same as the well-known JavaDoc before the first line of method source code as below.

http://farm6.staticflickr.com/5494/11336530824_f6cf0159a9_o.png

3. After you finish all documentations, use tcode CLASS_DOCUGEN to generate documentation:

 

http://farm6.staticflickr.com/5528/11336569563_ef198d42af_o.png

http://farm6.staticflickr.com/5480/11336505366_0ab98162d4_o.png

4. in class builder, click button to view generated documentation:

http://farm4.staticflickr.com/3749/11336569513_40b609c5fc_o.png

http://farm6.staticflickr.com/5522/11336505236_7d5e989231_o.png

 

http://farm6.staticflickr.com/5476/11336530594_40b37a5b6b_o.png

I would like to get a list of all classes which have methods registered to the event NEW_FOCUS of CL_BSP_WD_COLLECTION_WRAPPER.

 

When I try to use "where used list", I  wait more than ten minutes and could not get search result. It seems the number of hits are too large.

 

http://farm8.staticflickr.com/7395/11306057494_806372ba8b_o.png

So I schedule the search as background job by clicking button "In the Background". However it still took long time for me to get the result.

   http://farm3.staticflickr.com/2886/11321090424_a31d06e97b_o.png

 

then I try repository information system in SE80:

http://farm6.staticflickr.com/5521/11306104493_0a3eaeb335_o.png

Unfortunately it just return the class which defines that event.

http://farm3.staticflickr.com/2836/11305995385_d7da8ea6dc_o.png

I know I can use ST05 to find the transparent table which stores the definition of class method. However there is a more rapid way.

Use tcode SM50, then I found the long-running process for where used list function. It clearly shows that the process is reading on view VSEOCOMPDF.

 

http://farm3.staticflickr.com/2821/11306057334_8f13a398a4_o.png

Have a look at this view in SE11:

http://farm6.staticflickr.com/5497/11306104303_499c27f352_o.png  

Then I try with table SEOCOMPODF:

http://farm4.staticflickr.com/3712/11306057214_e47db85d03_o.png

Then I got the list

http://farm8.staticflickr.com/7303/11306057264_04efc8250e_o.png

ABAP Managed Database Procedures are new feature available in AS ABAP 7.40, SP05 which enables you to manage and call stored procedures or database procedure in AS ABAP. An ABAP Managed Database Procedure is a procedure written in its database-specific language (Native SQL, SQLScript, ...) implemented in an AMDP method of an AMDP class.

 

 

I use a simple example to show how it works. In line 21 the check is done against database type. Since I will demonstrate to manage and call store procedure writtin in SQLScript in HANA, the sample must be running in HANA DB.

http://farm6.staticflickr.com/5473/11303408906_88f9f419c6_o.png

http://farm3.staticflickr.com/2809/11303432254_5a6ef6e018_o.png

Then in line 26 a pop up is displayed to allow user input how much price he would like to increase. In line 33, the price is increased by calling

HANA store procedure, with the help of AMDP class CL_DEMO_AMDP.

 

An AMDP class to handle with HANA stuff must inherit the tag interface IF_AMDP_MARKER_HDB 

http://farm4.staticflickr.com/3832/11303376995_9ce72c0e7b_o.png

And AMDP method must specify the database type ( HDB ) and language type ( SQLSCRIPT ) using keyword shown below.

The ":" in line 4 and line 5 are specific syntax of SQLScript - the importing parameter should have it as prefix.

http://farm8.staticflickr.com/7372/11303376945_36b91f586f_o.png

The most important part is the AMDP class could not be developed in SAP GUI, but only possible in ABAP development Tools ( i.e ABAP in Eclipse)

http://farm6.staticflickr.com/5506/11303418906_be85370fe6_o.png

http://farm3.staticflickr.com/2844/11303408616_6ab2c8d047_o.png

Every AMDP method corresponds to a store procedure which you can find in HANA studio. Or you can also find it via ST05:

http://farm8.staticflickr.com/7314/11303432054_ff70a15540_o.png

Actions

Filter Blog

By author:
By date:
By tag: