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

/wp-content/uploads/2013/12/1_350361.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


/wp-content/uploads/2013/12/2_350364.png


5. Status :

Status is used to identify the processing status of Recipe .

/wp-content/uploads/2013/12/3_350363.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

/wp-content/uploads/2013/12/2_350364.png

Standard Values

Standard values are used in customization of work center

/wp-content/uploads/2013/12/3_350363.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 .

/wp-content/uploads/2013/12/2_350364.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 /wp-content/uploads/2013/12/2_350364.png

then click on Generate Relation Button at the bottom /wp-content/uploads/2013/12/2_350364.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 :

/wp-content/uploads/2013/12/2_350364.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 .

/wp-content/uploads/2013/12/5_350477.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 :

/wp-content/uploads/2013/12/5_350477.png

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

/wp-content/uploads/2013/12/2_350364.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.

/wp-content/uploads/2013/12/3_350363.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

/wp-content/uploads/2013/12/3_350363.png

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

/wp-content/uploads/2013/12/3_350363.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.

/wp-content/uploads/2013/12/4_350452.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 rc27mmatnr,
lv_stlal
TYPE maststlal,
lv_verid
TYPE mkalverid,
lv_phseq
TYPE plpophseq,
lv_losbs
TYPE char13,
lv_bstma
TYPE char13,
lv_bstmi
TYPE char13,
gd_msg  
TYPE string,
lv_date 
TYPE rn1datumdatex,
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 rc271plnnr,
lv_plnal
TYPE rc271plnal,
lv_losvn
TYPE rc271losvn,
lv_stlan
TYPE maststlan,
lv_len  
TYPE i,
lv_lines
TYPE i,

lv_phassign  TYPE zsbom_itemszph_assign,
lv_text     
TYPE char40,
lv_maktx    
TYPE maktx,
lv_prod_desc
TYPE maktx,
lv_plnkn    
TYPE plnkn,
lv_objek    
TYPE inobobjek,
lv_cuobj    
TYPE inobcuobj,

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 cabnatinn,
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 
= sydatum
format = ‘DD.MM.YYYY’
IMPORTING
datex 
= lv_date.

lv_matnr  = im_recipe_hmatnr.
lv_verid 
= im_recipe_hverid.   “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_hmaktx WHERE matnr = lv_matnr.

lv_werks = wa_recipe_hwerks.
lv_prof 
= wa_recipe_hprofidnetz. “pi01
lv_stat 
= wa_recipe_hstatu.” wa_recipe_h-statu.
lv_verwe
= wa_recipe_hverwe.“wa_recipe_h-verwe.
lv_vagrp
= wa_recipe_hvagrp.
lv_bmsch
= wa_recipe_hbmsch.
lv_ktext
= wa_recipe_hktext.
lv_plnme
= wa_recipe_hplnme.
lv_meinh
= wa_recipe_hmeinh.
lv_maktx
= wa_recipe_hmaktx.
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_hwerks CP ’10*’ .
lv_prod_desc
= wa_recipe_hmaktx.
ELSEIF wa_recipe_hwerks CP ’20*’.
lv_prod_desc
= wa_recipe_hmpr_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_hwerks CP ’10*’.

lv_bstmi = im_recipe_hbmsch“base quantity
lv_bstma
= im_recipe_hbmsch.
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_maststlnr IS NOT INITIAL.
lv_stlal
= wa_maststlal.
lv_stlan
= wa_maststlan.

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 = sytabix.
gd_opt 
= gd_opt + 1 .

IF  sytabix > 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_iphflg 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_ipvznr“Superordinate Operation

CLEAR gd_phseq.
CONCATENATE ‘PLPOD-PHSEQ(‘ gd_opt ‘)’ INTO gd_phseq.
CONDENSE gd_phseq.
PERFORM bdc_field       USING gd_phseq  wa_recipe_iphseq“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_ivornr.

CLEAR gd_arbpl.
CONCATENATE ‘PLPOD-ARBPL(‘ gd_opt ‘)’ INTO gd_arbpl.
CONDENSE gd_arbpl.
PERFORM bdc_field       USING gd_arbpl  wa_recipe_iarbpl.   ” Resource

CLEAR gd_steus.
CONCATENATE ‘PLPOD-STEUS(‘ gd_opt ‘)’ INTO gd_steus.
CONDENSE gd_steus.
PERFORM bdc_field       USING gd_steus wa_recipe_isteus. ” 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_iltxa1” 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_ibmsch .

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_imeinh.

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_iphflg = ‘X’.

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

SELECT SINGLE *
FROM crhd INTO wa_crhd WHERE arbpl = wa_recipe_iarbpl
AND  werks = im_recipe_hwerks.

IF wa_recipe_ivgw01 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_ivgw01.

PERFORM bdc_field       USING ‘BDC_CURSOR’
gd_vgw01
.
PERFORM bdc_field       USING ‘RC27X-ENTRY_ACT’
‘1’.
gd_qty_tmp
= wa_recipe_ivgw01.
CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING  gd_vgw01
gd_qty_tmp
.

CLEAR gd_qty_tmp.

“Standard Key UOM
IF wa_crhdvge01 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_crhdvge01
language = sylangu
IMPORTING
output   = wa_crhdvge01.

PERFORM bdc_field       USING  gd_vge
wa_crhd
vge01.
ENDIF.

ENDIF.

IF wa_recipe_ivgw02 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_ivgw02.
CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING gd_vgw02
gd_qty_tmp
.

IF wa_crhdvge02 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_crhdvge02
language = sylangu
IMPORTING
output   = wa_crhdvge02.

PERFORM bdc_field       USING  gd_vge
wa_crhd
vge02.
ENDIF.
ENDIF.

IF wa_recipe_ivgw03 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_ivgw03.
CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING  gd_vgw03
gd_qty_tmp
.

IF wa_crhdvge03 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_crhdvge03
language = sylangu
IMPORTING
output   = wa_crhdvge03.

PERFORM bdc_field       USING  gd_vge
wa_crhd
vge03.
ENDIF.
ENDIF.

IF wa_recipe_ivgw04 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_ivgw04.
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_crhdvge04
language = sylangu
IMPORTING
output   = wa_crhdvge04.

PERFORM bdc_field       USING  gd_vge
wa_crhd
vge04.
ENDIF.
ENDIF.

IF wa_recipe_ivgw05 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_ivgw05.
CONDENSE gd_qty_tmp.

PERFORM bdc_field       USING gd_vgw05
gd_qty_tmp
.

“Standard Key UOM


IF wa_crhdvge05 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_crhdvge05
language = sylangu
IMPORTING
output   = wa_crhdvge05.

PERFORM bdc_field       USING  gd_vge
                                                    wa_crhd
vge05.
ENDIF.
ENDIF.

IF wa_recipe_ivgw06 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_ivgw06.
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_crhdvge06
language = sylangu
IMPORTING
output   = wa_crhdvge06.

IF wa_crhdvge06 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_ivgw01 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_hwerks 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
= sytabix.

IF im_recipe_hplnme NE wa_recipe_imeinh AND im_recipe_hwerks CP ’20*’.

lv_lst_ind = gd_opt1.

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

lv_count = lv_lines sytabix .

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_hbmsch / wa_recipe_ibmsch“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_hwerks 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  = sytabix.
ld_cnt1 
= ld_cnt1 + 1.

IF wa_recipe_iphflg NE ‘X’ AND wa_recipe_iclass IS NOT INITIAL .

lv_count = lv_lines sytabix .

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_iclass.

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_iatwrt1 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_iatwrt2 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_iatwrt3 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_iatwrt4 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_iatwrt5 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_iatwrt6 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_hreinr
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_itemzph_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 sytabix .

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_itemzph_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 sysubrc NE 0.

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

CLEAR gd_msg.
CALL FUNCTION ‘FORMAT_MESSAGE’
EXPORTING
id        = wa_msgtabmsgid
lang     
= wa_msgtabmsgspra
no        = wa_msgtabmsgnr
v1       
= wa_msgtabmsgv1
v2       
= wa_msgtabmsgv2
v3       
= wa_msgtabmsgv3
v4       
= wa_msgtabmsgv4
IMPORTING
msg      
= gd_msg
EXCEPTIONS
not_found
= 1
OTHERS    = 2.
IF sysubrc <> 0.
MESSAGE ID symsgid TYPE symsgty NUMBER symsgno
WITH symsgv1 symsgv2 symsgv3 symsgv4.
ENDIF.

wa_returnid = wa_msgtabmsgid.
wa_return
number = wa_msgtabmsgnr.
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


To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. jeetendra choudhary

    Nice step by step Document Lokeswar will definitely try this one, now I know your secret Recipe 🙂

    Waiting for some content from you for gateway services too.

    Thanks & Regards

    Jeetendra

    (0) 

Leave a Reply