You are on page 1of 15

BDC Recording to Change Vendor Name in SAP

Create Recording
- Open tcode SHDB

- Click New Recording

- Fill Recording name and Transaction Code

click Start Recording. It will display screen of FK02 transaction.

- Fill Vendor code. Choose one option


- Change one column, for example Postal Code,
from..

to...

- Click Save
- Change Postal Code and click Save

- Recording result will be diplayed


Recording will keep all column that can be filled / can be changed, whether we change it ( for example
postal code) or not.

- Click Export button

- Save in local file

- Click Back

- Click Yes
- Select recording that was created before and click Program

- Give Program Name

- Give title name and click Source


- Save in local or in package
- It will automatically create porgram with name as we fill above

- Create simple program to change Vendor Title using some part of syntax in program
YTEST_BDC_DATA.

Note : BDC main purpose is to get information about program name, screen number and field name that
was used in a tcode. No need to create program YTEST_BCD_DATA. If we already have another Z
program that use BDC syntax inside, copy that program, and get program name, screen number & field
name, from the list below (tcode SHDB) :
Create Program
- Create program YTEST_CHANGE_VENDOR_POSTALCODE to change Vendor Title

- Create global data


DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

- Create selection screen input to fill Vendor Code ( vendor that we want to change its title)
and selection screen input to fill Postal Code
PARAMETERS : p_vendor TYPE lfa1-lifnr, "Vendor Code
p_pstl TYPE lfa1-pstlz. "Postal Code

- Create selection screen input to fill parameter for DBC (input mode and display mode)
PARAMETERS : ctumode LIKE ctu_params-dismode DEFAULT 'N', "BDC Display Mode
cupdate LIKE ctu_params-updmode DEFAULT 'S'. "BDC Update Mode

- Fill internal table bdcdata


Each screen in transaction must start with bdc_dynpro routine and have minimal 1 bdc_field
routine, for example :

First Screen
PERFORM bdc_dynpro USING 'SAPMF02K' '0106'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'RF02K-LIFNR' p_vendor.
PERFORM bdc_field USING 'RF02K-D0110 'X'.

Second Screen
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_OKCODE' '=UPDA'.
PERFORM bdc_field USING 'LFA1-PSTLZ' pstlcode.

Note :
First Screen
PERFORM bdc_dynpro USING 'SAPMF02K' '0106'.
==> means Program 'SAPMF02K' screen '0106' in tcode FK02
PERFORM bdc_field USING 'RF02K-D0110 'X'.
==> means we choose one option in Program 'SAPMF02K' screen '0106'

PERFORM bdc_field USING 'RF02K-LIFNR' p_vendor


==> means we will fill/change field 'RF02K-LIFNR' in program 'SAPMF02K' screen '0106'
(Tcode FK02) with value from p_vendor

PERFORM bdc_field USING 'BDC_OKCODE' '/00'.


==> means command for the screen such us Save, Enter, Back, etc
Note :
Second Screen

PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.


==> means Program 'SAPMF02K' screen '0110' in tcode FK02
PERFORM bdc_field USING 'LFA1-PSTLZ' p_pstl.

PERFORM bdc_field USING 'BDC_OKCODE' '=UPDA'.

- Call transaction that we want to process with the parameter in internal table bdcdata
REFRESH messtab.
CALL TRANSACTION 'FK02' USING bdcdata
MODE ctumode
UPDATE cupdate
MESSAGES INTO messtab.
LOOP AT messtab.
MESSAGE ID messtab-msgid
TYPE messtab-msgtyp
NUMBER messtab-msgnr
INTO l_mstring
WITH messtab-msgv1
messtab-msgv2
messtab-msgv3
messtab-msgv4.
WRITE: / messtab-msgtyp, l_mstring(250).
ENDLOOP.

Note :
- bdcdata : internal table whic the datc collected from routine bdc_dynpro and bdc_field

- ctumode : how bdc will be processed


N : screen will not be dipslayed
A : Show each screen while processing
E : Show screen if there any error

- cupdate : how transaction will be updated


S: synchronously
A: asynchronously
L: local

- messtab : contain message from BDC processing (success or error)

Example of running program


Run with CTUMODE (Display Mode) = 'N'.
- Postal Code for Vendor 7128002 (before update via program BDC / program
YTEST_CHANGE_VENDOR_POSTALCODE)
- Change postal code to 654321 through program YTEST_CHANGE_VENDOR_POSTALCODE

- Result

Run with CTUMODE (Display Mode) = 'A'.

- Fill data as screen below

- Result
press enter
press enter

check FK02 again


postal code has been changed.

You might also like