‎2006 Jun 28 1:09 PM
Hi all,
Can u explain me how to handle table control in BDC with coding.
Thanks in Advance
Venkat
‎2006 Jun 28 1:13 PM
Hi Venkat,
Please check this links.
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.sapfans.com/sapfans/repos/comelite.htm
http://arthur_ong.tripod.com/xab023.htm
Hope this will help.
Regards,
Ferry Lianto
Please reward points if helpful.
‎2006 Jun 28 1:13 PM
Hi Venkat,
Please go through these examples.
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm
You can also refer this link
http://www.sap-img.com/abap/question-about-bdc-program.ht
Award points to all the helpful answers.
Regards,
SP.
‎2006 Jun 28 1:15 PM
In case you want to pass the data to a specific row of a table control, you have to identify the index of that row.
lets say screen field name is vbap-matnr and you have to fill the 3rd row of the table control. In such a case you have to concatenate 'VBAP-MATNR(' '03' ')' into a variable (L_FIELD).
and call the perform for field -
PERFORM BDC_FIELD USING L_FIELD L_VALUE.
Hope it helps,
Amit
‎2006 Jun 28 1:26 PM
Hi,
Have a look at the following links-
Table control in BDC
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
BDC
http://www.sap-img.com/bdc.htm
www.sappoint.com/abap/bdcconcept.pdf
www.sap-img.com/abap/learning-bdc-programming.htm
www.sap-img.com/abap/question-about-bdc-program.htm
www.sapdevelopment.co.uk/bdc/bdchome.htm
www.planetsap.com/bdc_main_page.htm
Reward if helpful.
Regards,
Tanuja.
‎2006 Jun 28 1:30 PM
Hi venkat ,
Below is sample prg u can go thru..
report Z_BDC_KIRAN
no standard page heading line-size 255.
DATA:BEGIN OF ITAB OCCURS 0,
BUKRS LIKE RF02K-BUKRS,
KTOKK LIKE RF02K-KTOKK,
ANRED LIKE LFA1-ANRED,
NAME1 LIKE LFA1-NAME1,
SORTL LIKE LFA1-SORTL,
LAND1 LIKE LFA1-LAND1,
END OF ITAB.
DATA:IT_BDC TYPE TABLE OF BDCDATA WITH HEADER LINE,
IT_MESSAGES TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE,
IT_MESS(125),cnt type I.
*include bdcrecx1.
start-of-selection.
perform upload.
LOOP AT ITAB.
perform bdc_dynpro using 'SAPMF02K' '0105'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-BUKRS'
ITAB-BUKRS.
perform bdc_field using 'RF02K-KTOKK'
ITAB-KTOKK.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-ANRED'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFA1-ANRED'
ITAB-ANRED.
perform bdc_field using 'LFA1-NAME1'
ITAB-NAME1.
perform bdc_field using 'LFA1-SORTL'
ITAB-SORTL.
perform bdc_field using 'LFA1-LAND1'
ITAB-LAND1.
perform bdc_transaction using 'FK01'.
CALL TRANSACTION 'FK01' USING IT_BDC MODE 'N' MESSAGES INTO IT_MESSAGES.
IF SY-SUBRC <> 0.
CNT = CNT + 1.
if cnt = 1.
perform open_group.
endif.
PERFORM BDC_INSERT.
ENDIF.
clear :it_bdc[],it_bdc.
ENDLOOP.
PERFORM FORMAT_MESSAGES.
IF CNT > 1.
PERFORM CLOSE_GROUP.
ENDIF.
FORM UPLOAD .
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = ' '
FILETYPE = ' '
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
data_tab = itab
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " upload
form bdc_dynpro using program dynpro.
clear IT_bdc.
IT_BDC-PROGRAM = program.
IT_BDC-DYNPRO = DYNPRO.
IT_BDC-DYNBEGIN = 'X'.
APPEND IT_BDC.
endform.
----
Insert field *
----
form bdc_field using fnam fval.
if fval <> ''.
CLEAR IT_BDC.
IT_BDC-FNAM = fnam.
IT_BDC-FVAL = fval.
APPEND IT_BDC.
endif.
endform.
&----
*& Form FORMAT_MESSAGES
&----
form FORMAT_MESSAGES .
LOOP AT IT_MESSAGES.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = IT_MESSAGES-MSGID
LANG = SY-LANGU
NO = IT_MESSAGES-MSGNR
V1 = IT_MESSAGES-MSGV1
V2 = IT_MESSAGES-MSGV2
V3 = IT_MESSAGES-MSGV3
V4 = IT_MESSAGES-MSGV4
IMPORTING
MSG = IT_MESS
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/10 IT_MESS.
ENDLOOP.
endform. " FORMAT_MESSAGES
&----
*& Form BDC_INSERT
&----
FORM BDC_INSERT .
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'fk01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
DYNPROTAB = IT_BDC
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BDC_INSERT
&----
*& Form open_group
&----
FORM open_group .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = 'KIRRU1'
HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
RECORD = FILLER1
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " open_group
&----
*& Form CLOSE_GROUP
&----
FORM CLOSE_GROUP .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CLOSE_GROUP
Regards,
Kiran B
‎2006 Jun 28 1:35 PM
hi,
REPORT ZSUDHA_CALLTRANSCATIONEX5 .
*----
internal table for uploading data
data:begin of itab occurs 0,
lifnr like lfa1-lifnr,
bukrs type lfb1-bukrs,
anred like lfb1-anred,
name1 like lfa1-name1,
sortl like lfa1-sortl,
land1 like lfa1-land1,
spras like lfa1-spras,
ktokk like lfa1-ktokk,
end of itab.
data:flag type c.
*----
Internal Table for uploadind bank details
data:begin of it_bank occurs 0,
lifnr like lfa1-lifnr,
banks like lfbk-banks,
bankl like lfbk-bankl,
bankn like lfbk-bankn,
end of it_bank.
data:it_bdc type bdcdata occurs 0 with header line,
it_msg type bdcmsgcoll occurs 0 with header line.
*----
selection screen
selection-screen begin of block b1 with frame title text-001.
parameters:p_file type rlgrap-filename ,
p_file1 type rlgrap-filename.
selection-screen end of block b1.
*---- at selection-screen
at selection-screen on value-request for p_file.
perform get_help using p_file.
at selection-screen on value-request for p_file1.
perform get_help using p_file1.
start-of-selection.
perform upload_file using p_file p_file1.
perform populate_bdc.
&----
*& Form get_help
&----
text
----
-->P_P_FILE text
----
form get_help using p_p_file.
data:l_file type ibipparms-path.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = l_file.
p_p_file = l_file.
endform. " get_help
&----
*& Form upload_file
&----
text
----
-->P_P_FILE text
-->P_P_FILE1 text
----
form upload_file using p_p_file
p_p_file1.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = p_p_file
FILETYPE = 'ASC'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = itab
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = p_p_file1
FILETYPE = 'ASC'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = it_bank
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " upload_file
&----
*& Form populate_bdc
&----
text
----
--> p1 text
<-- p2 text
----
form populate_bdc .
data:l_counter type n,
l_string type string.
loop at itab.
perform bdc_dynpro using 'SAPMF02K' '0105'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
itab-lifnr.
perform bdc_field using 'RF02K-BUKRS'
itab-bukrs.
perform bdc_field using 'RF02K-KTOKK'
itab-ktokk.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-LAND1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'LFA1-ANRED'
itab-anred.
perform bdc_field using 'LFA1-NAME1'
itab-name1.
perform bdc_field using 'LFA1-SORTL'
itab-sortl.
perform bdc_field using 'LFA1-LAND1'
itab-land1.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-XEZER(01)'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
clear l_counter.
loop at it_bank where lifnr = itab-lifnr.
l_counter = l_counter + 1.
clear l_string.
concatenate 'lfbk-banks(' l_counter ')' into l_string.
perform bdc_field using l_string
it_bank-banks.
clear l_string.
concatenate 'lfbk-bankl(' l_counter ')' into l_string.
perform bdc_field using l_string
it_bank-bankl.
clear l_string.
concatenate 'lfbk-bankn(' l_counter ')' into l_string.
perform bdc_field using l_string
it_bank-bankn.
clear l_string.
endloop.
call transaction 'FK01' using it_bdc mode 'A' messages into it_msg.
*write:/ sy-subrc.
if sy-subrc ne 0.
perform create_session.
endif.
clear it_bdc.
refresh it_bdc.
endloop.
if flag = 'X'.
perform close_group.
endif.
endform.
" populate_bdc
&----
*& Form bdc_dynpro
&----
text
----
-->P_0253 text
-->P_0254 text
----
form bdc_dynpro using value(p_0253)
value(p_0254).
it_bdc-program = p_0253.
it_bdc-dynpro = p_0254.
it_bdc-dynbegin = 'X'.
append it_bdc.
clear it_bdc.
endform. " bdc_dynpro
&----
*& Form bdc_field
&----
text
----
-->P_0338 text
-->P_0339 text
----
form bdc_field using value(p_0338)
value(p_0339).
it_bdc-fnam = p_0338.
it_bdc-fval = p_0339.
it_bdc-dynbegin = 'X'.
append it_bdc.
clear it_bdc.
endform. " bdc_field
&----
*& Form create_session
&----
text
----
--> p1 text
<-- p2 text
----
form create_session .
if flag = ' '.
perform bdc_open.
flag = 'X'.
endif.
perform bdc_insert.
endform. " create_session
&----
*& Form bdc_open
&----
text
----
--> p1 text
<-- p2 text
----
form bdc_open .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = 'zsita'
HOLDDATE = FILLER8
KEEP = 'X'
USER = sy-uname
RECORD = FILLER1
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " bdc_open
&----
*& Form close_group
&----
text
----
--> p1 text
<-- p2 text
----
form close_group .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " close_group
&----
*& Form bdc_insert
&----
text
----
--> p1 text
<-- p2 text
----
form bdc_insert .
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'FK01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
dynprotab = it_bdc
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform format_messages.
clear: it_bdc,it_msg.
refresh: it_bdc,it_msg.
endform. " bdc_insert
&----
*& Form format_messages
&----
text
----
--> p1 text
<-- p2 text
----
form format_messages .
DATA: v_msg TYPE string.
LOOP AT it_msg WHERE msgtyp = 'S' OR
msgtyp = 'E'.
CLEAR v_msg.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = it_msg-msgid
LANG = sy-langu
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = v_msg
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endloop.
write:/ itab-lifnr,v_msg.
endform. " format_messages
hope this helps .
regards,
keerthi.
‎2006 Jun 28 2:01 PM
Hi Venkat,
Table control/ BDC.. can I know which piece exactly you are looking for.. Then I can give better example for that.
-Pavan