10-06-2008 10:21 AM
Hi All,
I need to create a bdc for tcode 0vrf. In first screen i need to pass 4 fields and in second screen i need to pass 3 fields. In second screen records can be multiple. how to write a bdc for this. Could you please suggest me?
10-06-2008 10:23 AM
Hi
Are u saying if the records are multiple per transaction then u have to use Table Control* method.. to know more about table control, search in SDN..
Regards,
Vishwa.
Edited by: vishwa sri hari on Oct 6, 2008 2:53 PM
10-06-2008 10:27 AM
hi sreekala,
this is a code for va01..use this u can easily get it...
report ZB_VA01
no standard page heading line-size 255.
Types: begin of ty_head,
PO_number(40),
bldat(10),
budat(10),
LFSNR(50),
BKTXT(50),
* VENDORNAME(20),
numb1 type i,
End of ty_head.
Types: begin of ty_item,
ERFMG(20),
lsmng(20),
lgobe(20),
vendorname(20),
numb2 type i,
End of ty_item.
data: it_head type table of ty_head. " Header
data: wa_head like line of it_head.
data: it_item type table of ty_item. " Item
data: wa_item like line of it_item.
data:V_ZEILE(30) type c,
V_ERFMG(30) TYPE C.
PARAMETERS: filename LIKE rlgrap-filename.
PARAMETERS: filenam1 LIKE rlgrap-filename.
DATA: VAL(2) TYPE N VALUE 01.
DATA: val1(4) type c VALUE ' 1'.
DATA : w_file2 TYPE string,
w_file1 TYPE string.
include zbdcrecx1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filenam1.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = filenam1.
START-OF-SELECTION.
w_file2 = filename.
w_file1 = filenam1.
*************** HEADER ************************
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file2
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_head.
*************** Item *******************
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file1
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_item.
perform open_group.
loop at it_head into wa_head.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
perform bdc_field using 'GODYNPRO-ACTION'
'A01'.
perform bdc_field using 'GODYNPRO-REFDOC'
'R01'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
perform bdc_field using 'BDC_CURSOR'
'GODYNPRO-PO_NUMBER'.
perform bdc_field using 'GODYNPRO-PO_NUMBER'
wa_head-po_number.
perform bdc_field using 'GOHEAD-BLDAT'
wa_head-bldat.
perform bdc_field using 'GOHEAD-BUDAT'
wa_head-budat.
perform bdc_field using 'GOHEAD-WEVER'
'3'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
perform bdc_field using 'BDC_CURSOR'
'GOHEAD-BKTXT'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
perform bdc_field using 'GOHEAD-LFSNR'
wa_head-lfsnr.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
perform bdc_field using 'GOHEAD-BKTXT'
wa_head-bktxt.
perform bdc_field using 'GOHEAD-WEVER'
'3'.
perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
' 1'.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* '100'.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=MIGO_OK_LINE_CLICK'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
perform bdc_field using 'GOHEAD-WEVER'
'3'.
CONCATENATE 'GOITEM-ZEILE(' VAL ')' INTO V_ZEILE.
loop at it_item into wa_item where NUMB2 eq wa_head-NUMB1.
if val = 01.
perform bdc_field using 'BDC_CURSOR'
V_ZEILE.
*perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
* ' 1'.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* '100'.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
*perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
* ' 1'.
perform bdc_field using 'BDC_CURSOR'
'GOITEM-ERFMG'.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
perform bdc_field using 'GOITEM-ERFMG'
WA_iTEM-ERFMG.
perform bdc_field using 'GOITEM-LSMNG'
wa_item-lsmng.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
*perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
* ' 1'.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* '100'.
*perform bdc_field using 'GOITEM-LSMNG'
* '100.000'.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
perform bdc_field using 'BDC_CURSOR'
'GOITEM-LGOBE'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
perform bdc_field using 'GOITEM-LGOBE'
wa_item-lgobe.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
*perform bdc_field using 'GODEFAULT_TV-BWART'
* '101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
*perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
* ' 1'.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* '100'.
*perform bdc_field using 'GOITEM-LSMNG'
* '100.000'.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
*perform bdc_field using 'GOITEM-LGOBE'
* 'Raw Materials'.
perform bdc_field using 'BDC_CURSOR'
'GOFREIGHT-VENDORNAME(01)'.
perform bdc_field using 'GOFREIGHT-VENDORNAME(01)'
wa_item-vendorname.
perform bdc_field using 'BDC_CURSOR'
'GODYNPRO-DETAIL_TAKE'.
perform bdc_field using 'GODYNPRO-DETAIL_TAKE'
'X'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=MIGO_OK_LINE_CLICK'.
*******perform bdc_field using 'GODEFAULT_TV-BWART'
******* '101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
else.
*VAL = VAL + 01.
CONCATENATE 'GOITEM-ZEILE(' VAL ')' INTO V_ZEILE.
perform bdc_field using 'BDC_CURSOR'
V_ZEILE.
perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
VAL1.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* WA_iTEM-ERFMG.
*perform bdc_field using 'GOITEM-LSMNG'
* wa_item-lsmng.
perform bdc_field using 'GOITEM-MIGO_ELIKZ'
val1.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
*perform bdc_field using 'GOITEM-LGOBE'
* 'Raw Materials'.
*perform bdc_field using 'GODYNPRO-DETAIL_TAKE'
* 'X'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
*********perform bdc_field using 'GODEFAULT_TV-BWART'
********* '101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*********perform bdc_field using 'GOHEAD-WEVER'
********* '3'.
val1 = val1 + ' 1'.
perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
val1.
perform bdc_field using 'BDC_CURSOR'
'GOITEM-LSMNG'.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
perform bdc_field using 'GOITEM-ERFMG'
wa_item-ERFMG.
perform bdc_field using 'GOITEM-LSMNG'
wa_item-lsmng.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
val1.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* '100'.
*perform bdc_field using 'GOITEM-LSMNG'
* '100.000'.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
perform bdc_field using 'BDC_CURSOR'
'GOITEM-LGOBE'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
perform bdc_field using 'GOITEM-LGOBE'
wa_item-lgobe.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_GO'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
val1.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* '100'.
*perform bdc_field using 'GOITEM-LSMNG'
* '100.000'.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
*perform bdc_field using 'GOITEM-LGOBE'
* 'Raw Materials'.
perform bdc_field using 'BDC_CURSOR'
'GODYNPRO-DETAIL_TAKE'.
perform bdc_field using 'GODYNPRO-DETAIL_TAKE'
'X'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=MIGO_OK_LINE_CLICK'.
********perform bdc_field using 'GODEFAULT_TV-BWART'
******** '101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
*VAL = VAL - 01.
endif.
val = val + 01.
endloop.
***perform bdc_field using 'BDC_CURSOR'
*** 'GOITEM-ZEILE(03)'.
***perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
*** ' 2'.
***perform bdc_field using 'GOITEM-ERFME'
*** 'KG'.
***perform bdc_field using 'GOITEM-ERFMG'
*** '100'.
***perform bdc_field using 'GOITEM-LSMNG'
*** '100.000'.
***perform bdc_field using 'GOITEM-MIGO_ELIKZ'
*** '1'.
***perform bdc_field using 'GOITEM-BWART'
*** '101'.
***perform bdc_field using 'GOITEM-LGOBE'
*** 'Raw Materials'.
***perform bdc_field using 'GODYNPRO-DETAIL_TAKE'
*** 'X'.
***perform bdc_dynpro using 'SAPLMIGO' '0001'.
***perform bdc_field using 'BDC_OKCODE'
*** '=OK_GO'.
***perform bdc_field using 'GODEFAULT_TV-BWART'
*** '101'.
***perform bdc_field using 'GOHEAD-BLDAT'
*** '19.06.2008'.
***perform bdc_field using 'GOHEAD-LFSNR'
*** '123XXXAPPU'.
***perform bdc_field using 'GOHEAD-BUDAT'
*** '19.06.2008'.
***perform bdc_field using 'GOHEAD-BKTXT'
*** '143to1234'.
***perform bdc_field using 'GOHEAD-WEVER'
*** '3'.
***perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
*** ' 3'.
***perform bdc_field using 'BDC_CURSOR'
*** 'GOITEM-LSMNG'.
***perform bdc_field using 'GOITEM-ERFME'
*** 'KG'.
***perform bdc_field using 'GOITEM-ERFMG'
*** '100'.
***perform bdc_field using 'GOITEM-LSMNG'
*** '100'.
***perform bdc_field using 'GOITEM-MIGO_ELIKZ'
*** '1'.
***perform bdc_field using 'GOITEM-BWART'
*** '101'.
***perform bdc_dynpro using 'SAPLMIGO' '0001'.
***perform bdc_field using 'BDC_OKCODE'
*** '=OK_GO'.
***perform bdc_field using 'GODEFAULT_TV-BWART'
*** '101'.
***perform bdc_field using 'GOHEAD-BLDAT'
*** '19.06.2008'.
***perform bdc_field using 'GOHEAD-LFSNR'
*** '123XXXAPPU'.
***perform bdc_field using 'GOHEAD-BUDAT'
*** '19.06.2008'.
***perform bdc_field using 'GOHEAD-BKTXT'
*** '143to1234'.
***perform bdc_field using 'GOHEAD-WEVER'
*** '3'.
***perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
*** ' 3'.
***perform bdc_field using 'GOITEM-ERFME'
*** 'KG'.
***perform bdc_field using 'GOITEM-ERFMG'
*** '100'.
***perform bdc_field using 'GOITEM-LSMNG'
*** '100.000'.
***perform bdc_field using 'GOITEM-MIGO_ELIKZ'
*** '1'.
***perform bdc_field using 'BDC_CURSOR'
*** 'GOITEM-LGOBE'.
***perform bdc_field using 'GOITEM-BWART'
*** '101'.
***perform bdc_field using 'GOITEM-LGOBE'
*** 'rmsl'.
***perform bdc_dynpro using 'SAPLMIGO' '0001'.
***perform bdc_field using 'BDC_OKCODE'
*** '=OK_GO'.
***perform bdc_field using 'GODEFAULT_TV-BWART'
*** '101'.
***perform bdc_field using 'GOHEAD-BLDAT'
*** '19.06.2008'.
***perform bdc_field using 'GOHEAD-LFSNR'
*** '123XXXAPPU'.
***perform bdc_field using 'GOHEAD-BUDAT'
*** '19.06.2008'.
***perform bdc_field using 'GOHEAD-BKTXT'
*** '143to1234'.
***perform bdc_field using 'GOHEAD-WEVER'
*** '3'.
***perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
*** ' 3'.
***perform bdc_field using 'GOITEM-ERFME'
*** 'KG'.
***perform bdc_field using 'GOITEM-ERFMG'
*** '100'.
***perform bdc_field using 'GOITEM-LSMNG'
*** '100.000'.
***perform bdc_field using 'GOITEM-MIGO_ELIKZ'
*** '1'.
***perform bdc_field using 'GOITEM-BWART'
*** '101'.
***perform bdc_field using 'GOITEM-LGOBE'
*** 'Raw Materials'.
perform bdc_field using 'BDC_CURSOR'
'GODYNPRO-DETAIL_TAKE'.
perform bdc_field using 'GODYNPRO-DETAIL_TAKE'
'X'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_CHECK'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
val1.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* '100'.
*perform bdc_field using 'GOITEM-LSMNG'
* '100.000'.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
*perform bdc_field using 'GOITEM-LGOBE'
* 'Raw Materials'.
perform bdc_field using 'BDC_CURSOR'
'GODYNPRO-DETAIL_TAKE'.
perform bdc_field using 'GODYNPRO-DETAIL_TAKE'
'X'.
perform bdc_dynpro using 'SAPLMIGO' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=OK_POST1'.
perform bdc_field using 'GODEFAULT_TV-BWART'
'101'.
*perform bdc_field using 'GOHEAD-BLDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-LFSNR'
* '123XXXAPPU'.
*perform bdc_field using 'GOHEAD-BUDAT'
* '19.06.2008'.
*perform bdc_field using 'GOHEAD-BKTXT'
* '143to1234'.
*perform bdc_field using 'GOHEAD-WEVER'
* '3'.
perform bdc_field using 'GODYNPRO-DETAIL_ZEILE'
val1.
*perform bdc_field using 'GOITEM-ERFME'
* 'KG'.
*perform bdc_field using 'GOITEM-ERFMG'
* '100'.
*perform bdc_field using 'GOITEM-LSMNG'
* '100.000'.
*perform bdc_field using 'GOITEM-MIGO_ELIKZ'
* '1'.
*perform bdc_field using 'GOITEM-BWART'
* '101'.
*perform bdc_field using 'GOITEM-LGOBE'
* 'Raw Materials'.
perform bdc_field using 'BDC_CURSOR'
'GODYNPRO-DETAIL_TAKE'.
perform bdc_field using 'GODYNPRO-DETAIL_TAKE'
'X'.
perform bdc_transaction using 'MIGO'.
endloop.
perform close_group.
regards,
Vamshi