To perform any Transactions through ABAP coding we have BAPI, Function Module or Class-Methods, But for few Transactions there are No direct BAPI, Function Module or Class-Methods, In this situation a developer chooses "BDC Call Transation Method" to Update the specific Transaction.
where as from Web Dynpro we cannot directly run the BDC.
A simple solution can execute BDC through Web Dynpro.
Below are the details of "How to Execute BDC in Web Dynpro" :
step 1) Create Recording for a specific Transaction using 'SHDB' and Transport the recording to a Executable Report Program .
step 2) Write the BDC coding for the Recording using CALL TRANSACTION METHOD. ( note : Always use MODE : 'N' )
Example : CALL TRANSACTION 'MM01' USING IT_BDCDATA MODE 'N'
UPDATE 'S'
MESSAGES INTO IT_MESSTAB_tmp.
NOTE : Do not place any output screen Results, like 'write' statements, it will give a short dump while we execute through Web Dynpro .
step 3) To exchange Data between Web Dynpro and Report Program we can export the result to Memory ID and Import the data in Web Dynpro from Memory ID.
Example : Export IT_MESSTAB from IT_MESSTAB_tmp TO MEMORY ID 'KRANTHI'.
step 4) Create a Web Dynpro Component and where ever it is necessary to trigger a BDC, SUBMIT to the Report Program using the below syntax.
Example : submit ztest_mm_demo2 with material_id = lv_matnr and return.
NOTE: here Material_ID is the Parameter of the Report Program, I am passing a Material_ID from WebDynpro to Report
Program.
step 5) After executing the Report Program which contains BDC the Result is Exported to a Memory ID from Report Program, we have to Import the Result from
Memory ID using the below Syntax .
Example : Import it_messtab to it_messtab_tmp from memory id 'KRANTHI'.
This is the simple solution how to Run the BDC through Web Dynpro.
Below I am placing a sample code for Creation of a Material using Web Dynpro & BDC.
***************************************************************************************
*** REPORT PROGRAM
***************************************************************************************
Report ZTEST_MM_DEMO2
**********************************************************************
** CREATION OF MATERIAL USING BASIC FIELDS
**********************************************************************
PARAMETERS : MATERIAL_ID TYPE MATNR.
DATA : IT_BDCDATA TYPE TABLE OF BDCDATA,
WA_BDCDATA TYPE BDCDATA.
DATA: IT_MESSTAB TYPE TABLE OF BDCMSGCOLL,
IT_MESSTAB_TMP TYPE TABLE OF BDCMSGCOLL,
WA_MESSTAB TYPE BDCMSGCOLL.
data : LV_MATNR TYPE MATNR,
LV_mbrsh TYPE mbrsh,
LV_MTART TYPE MTART,
LV_MAKTX TYPE MAKTX,
LV_MEINS TYPE MEINS.
****************************************************************************
**** KRANTHI KUMAR M SAP ABAP WEBDYNPRO ADOBEFORMS
****************************************************************************
start-of-selection.
LV_MATNR = MATERIAL_ID . " PASSING FROM WEBDYNPRO
LV_mbrsh = 'B'. " HARDCODED VALUE
LV_MTART = 'KMAT'. " HARDCODED VALUE
LV_MAKTX = 'MY BDC DESC BEV9'. " HARDCODED VALUE
LV_MEINS = 'BAG'. " HARDCODED VALUE
******************************************************************************
** BDC RECORDING
******************************************************************************
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR' " MATERIAL CODE
LV_MATNR . "'BEV1'.
perform bdc_field using 'RMMG1-MBRSH' " MBRSH
LV_mbrsh . "'B'.
perform bdc_field using 'RMMG1-MTART' " MTART
LV_MTART . "'KMAT'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX' " DESCRIPTION
LV_MAKTX . "'DESCRIPTION OF MAT'.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS' " UOM
LV_MEINS . "BAG'.
perform bdc_field using 'MARA-MTPOS_MARA'
'0002'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX' " DESCRIPTION
LV_MAKTX . "'DESCRIPTION OF MAT'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
** CALL TRANSACTION METHOD
CALL TRANSACTION 'MM01' USING IT_BDCDATA MODE 'N'
UPDATE 'S'
MESSAGES INTO IT_MESSTAB_tmp.
**EXPORTING RESULT DATA TO MEMORY ID, SO THAT WE CAN IMPORT IN WEBDYNPRO******
export IT_MESSTAB from IT_MESSTAB_tmp TO MEMORY ID 'KRANTHI'.
******************************************************************************
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear WA_bdcdata.
WA_bdcdata-program = program.
WA_bdcdata-dynpro = dynpro.
WA_bdcdata-dynbegin = 'X'.
append WA_bdcdata TO IT_BDCDATA.
endform.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
clear WA_bdcdata.
WA_bdcdata-fnam = fnam.
WA_Bdcdata-fval = fval.
append WA_bdcdata TO IT_BDCDATA.
endform.
***********************************************************************************
** WEBDYNPRO CODE ON ACTION OF A BUTTON
***********************************************************************************
method onactiontrigger .
data : it_messtab type table of bdcmsgcoll,
it_messtab_tmp type table of bdcmsgcoll .
data lo_nd_inp_fields type ref to if_wd_context_node.
data lo_el_inp_fields type ref to if_wd_context_element.
data ls_inp_fields type wd_this->element_inp_fields.
data lv_matnr type wd_this->element_inp_fields-matnr.
* navigate from <CONTEXT> to <INP_FIELDS> via lead selection
lo_nd_inp_fields = wd_context->get_child_node( name = wd_this->wdctx_inp_fields ).
* get element via lead selection
lo_el_inp_fields = lo_nd_inp_fields->get_element( ).
* get single attribute
lo_el_inp_fields->get_attribute(
exporting
name = `MATNR`
importing
value = lv_matnr ).
**** EXECUTING REPORT PROGRAM WITH BDC**************************
submit ztest_mm_demo2 with material_id = lv_matnr and return.
**** IMPORTING THE RESULT OF BDC *******************************
import it_messtab to it_messtab_tmp from memory id 'KRANTHI'.
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |