Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

2/5/2020 Executing BDC through Web Dynpro ( BDC Call transaction in Web Dynpro ) | SAP Blogs

Community

Ask a Question Write a Blog Post Login

Former Member
October 17, 2013 6 minute read

Executing BDC through Web Dynpro ( BDC Call transaction in Web Dynpro )
Follow RSS feed Like

4 Likes 3,317 Views 15 Comments

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 speci c 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 speci c 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

https://blogs.sap.com/2013/10/17/executing-bdc-through-web-dynpro-call-transaction-in-web-dynpro/ 1/7
2/5/2020 Executing BDC through Web Dynpro ( BDC Call transaction in Web Dynpro ) | SAP Blogs

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

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

https://blogs.sap.com/2013/10/17/executing-bdc-through-web-dynpro-call-transaction-in-web-dynpro/ 2/7
2/5/2020 Executing BDC through Web Dynpro ( BDC Call transaction in Web Dynpro ) | SAP Blogs

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 eld                                                  *
*———————————————————————-*
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( ).

https://blogs.sap.com/2013/10/17/executing-bdc-through-web-dynpro-call-transaction-in-web-dynpro/ 3/7
2/5/2020 Executing BDC through Web Dynpro ( BDC Call transaction in Web Dynpro ) | SAP Blogs

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

Alert Moderator

Assigned tags

ABAP Development | sap developer network | Web Dynpro | web dynpro abap |

Related Blog Posts

Web Dynpro ABAP Component and Application Editor


By Raghuvira BHAGAVAN , Oct 27, 2015

How to convert a front end BDC recording code(generated via SHDB) into a modular Code to be run in the background using ‘Call Transaction’ with error Log
By Fahad Javed , Nov 15, 2015

Developing ABAP Report into Web Dynpro ABAP one – Areas to be considered
By Former Member , Nov 06, 2013

Related Questions

BAPI or RFC for Transaction OBY6


By Amey Mogare , Apr 16, 2009
Can I use bdc in web dynpro?
By Former Member , Feb 19, 2007

BDC can work for Web Dynpro screens or not?


By Former Member , Jan 22, 2007

15 Comments

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

Former Member

October 17, 2013 at 9:50 am

I think this is the rst blog that starts with “Very useful tip.”.

After seeing the entry in activity feed, I thought that it is a comment to existing blog.

Like (0)

https://blogs.sap.com/2013/10/17/executing-bdc-through-web-dynpro-call-transaction-in-web-dynpro/ 4/7
2/5/2020 Executing BDC through Web Dynpro ( BDC Call transaction in Web Dynpro ) | SAP Blogs

Former Member | Post author

October 17, 2013 at 9:52 am

Thanks Manish

Like (0)

Former Member

October 17, 2013 at 9:58 am

Thanks Manish for u r good info..

Like (0)

Former Member

October 17, 2013 at 10:07 am

Hi Kranthi, this is very useful blog for everyone.

after a longtime i saw the rst blog regarding how to call a BDC through WDPro

Like (0)

Former Member | Post author

October 17, 2013 at 10:08 am

Thanks Shantan

Like (0)

Matthew Billingham

October 17, 2013 at 2:41 pm

Why use SUBMIT to launch the BDC? Why not program the BDC in a function module.

Like (0)

Former Member | Post author

October 17, 2013 at 4:13 pm

If we program the BDC in Function Module or Class Methods, when we try to run the Function Module or Class Methods through webdynpro it leads to short dump, as webdynpro will not work
with the Parameter ID’s . when you record a transaction the recording will contain the parameter ID’s hence it leads to short dump. where as here we are submiting the control to a Report
Program and Returning the Control to webdynpro.

Like (0)

Matthew Billingham

October 17, 2013 at 4:27 pm

hmm. I cannot understand why you should get a dump. Parameter IDs are stored on the application server. The backend of the webdynpro runs on the appserver. I’ve run BDC through function
modules starting a new task without di culty.

What is the nature of the dump you get? I want to get to the bottom of this!

(I’m so old that I used to do BDC by hand… before you could record them…!)

Like (0)

https://blogs.sap.com/2013/10/17/executing-bdc-through-web-dynpro-call-transaction-in-web-dynpro/ 5/7
2/5/2020 Executing BDC through Web Dynpro ( BDC Call transaction in Web Dynpro ) | SAP Blogs

Matthew Billingham

November 1, 2013 at 11:26 am

as webdynpro will not work with the Parameter ID’s

I’d still like an answer to this.

Like (0)

Syam Babu

October 21, 2013 at 12:52 pm

Hi Kranthi,

Excellent Stu .

Thanks,

Syam

Like (0)

Former Member | Post author

October 23, 2013 at 7:40 am

Thanks Syam

Thanks,

Kranthi Kumar M.

Like (0)

Former Member

November 1, 2013 at 10:45 am

Hi Kranthi ,

It’s Excellent keep posting further with good scenarios !!!

“Best Of Luck”.

Regard’s,

Shamsher

Like (0)

Former Member | Post author

November 5, 2013 at 6:32 am

Thanks shamsher,

preparing new doc’s will updarte soon..

Thanks,

Kranthi Kumar M.

Like (0)

https://blogs.sap.com/2013/10/17/executing-bdc-through-web-dynpro-call-transaction-in-web-dynpro/ 6/7
2/5/2020 Executing BDC through Web Dynpro ( BDC Call transaction in Web Dynpro ) | SAP Blogs

R Sampath Kumar

November 12, 2013 at 10:27 am

Nice useful info…

regards,

sampath kumar

Like (0)

Former Member | Post author

November 13, 2013 at 5:00 am

Thank you Sampath,

Thanks,

Kranthi Kumar M.

Like (0)

Find us on

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Cookie Preferences

Newsletter Support

https://blogs.sap.com/2013/10/17/executing-bdc-through-web-dynpro-call-transaction-in-web-dynpro/ 7/7

You might also like