Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BDC with table control & script

Former Member
0 Kudos

Hi experts,

1> Can anyone explain me how to pass data in table control with a example?

2> i have developed a layout in script for english language if the language is changed to chinese then the text in layouts are not coming properly. can u tell me what to do?

3>while doing bdc resolution problem is ariseing how to resolve it?

1 REPLY 1

Former Member
0 Kudos

Hi Pankaj,

Go through this , every thing is gatherd from threads itself, so before posting any question search it first.

All the best

Table control in BDC

http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

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

  • After recording using SHDB tcode, you have to save the generated code.

  • Select the recording name & click on Program to generate it.

  • Provide program name & check "Transfer from Recording" field contents.

  • Create a flat file with tab delimiters or Excel file with fields you have to enter into tablecontrol.

  • Field space must be as in the SAP table & provide the values for it.

  • If QTY & CURRENCY fields are there then change those fields to text in Excel file.

  • Save it as xls file & then Save As txt file.

  • While executing the program, select txt file for Uploading the Datas into Tablecontrol.

Ex:- ME51 transaction

REPORT ZK_ME51_01_NEW NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE BDCRECX1.

DATA: BEGIN OF ITAB OCCURS 0,

NUMBER(3),

MATNR LIKE EBAN-MATNR,

TXZ01 LIKE EBAN-TXZ01,

MENGE(13) TYPE C,

WERKS LIKE EBAN-WERKS,

LGORT(4),

END OF ITAB.

DATA: TABCT(2) TYPE C, "LINES IN FLAT FILE

CTL TYPE I, "

CTL1 TYPE C,

CTL2(3),

FINAL(3) TYPE C VALUE '0', " LAST VALUE IN FLAT FILE

PG(5) TYPE C VALUE '10', " FOR INCREMENTING THE PAGES

TEMPVAL(20) TYPE C.

START-OF-SELECTION.

PERFORM GETDATA.

PERFORM OPEN_GROUP.

SORT ITAB BY NUMBER.

LOOP AT ITAB.

IF ITAB-NUMBER NE FINAL.

PERFORM BDC_DYNPRO USING 'SAPMM06B' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EBAN-BSART'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'EBAN-BSART'

'NB'.

PERFORM BDC_FIELD USING 'RM06B-LPEIN'

'T'.

MOVE 0 TO CTL1.

MOVE 0 TO CTL.

LOOP AT ITAB WHERE NUMBER = ITAB-NUMBER.

CTL = CTL + 1.

CTL2 = CTL.

IF CTL2 >= 10.

CTL1 = ''.

ENDIF.

IF CTL >= 19.

CTL2 = '19'.

ENDIF.

IF CTL2 >= 19.

PG = PG + 10.

ENDIF.

PERFORM BDC_DYNPRO USING 'SAPMM06B' '0106'.

PERFORM BDC_FIELD USING 'RM06B-BNFPO'

PG.

CONCATENATE 'eban-lgort(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-LGORT.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

CONCATENATE 'eban-matnr(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-MATNR.

CONCATENATE 'eban-menge(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-MENGE.

CONCATENATE 'eban-meins(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL 'EA'.

CONCATENATE 'rm06b-eeind(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL '27.07.2007'.

CONCATENATE 'eban-ekgrp(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL '000'.

CONCATENATE 'eban-matkl(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL '001'.

CONCATENATE 'eban-werks(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-WERKS.

CONCATENATE 'eban-lgort(' CTL1 CTL2 ')' INTO TEMPVAL.

CONDENSE TEMPVAL NO-GAPS.

PERFORM BDC_FIELD USING TEMPVAL ITAB-LGORT.

PERFORM BDC_DYNPRO USING 'SAPMM06B' '0102'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'EBAN-MENGE'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'EBAN-TXZ01'

ITAB-TXZ01." 'Lubricating oil'.

PERFORM BDC_FIELD USING 'EBAN-LGORT'

ITAB-LGORT. " '0001'.

PERFORM BDC_FIELD USING 'EBAN-MENGE'

ITAB-MENGE. " '200'.

PERFORM BDC_FIELD USING 'RM06B-EEIND'

'30.07.2007'.

PERFORM BDC_FIELD USING 'RM06B-LPEIN'

'D'.

PERFORM BDC_FIELD USING 'EBAN-EKGRP'

'003'.

PERFORM BDC_FIELD USING 'EBAN-BADAT'

'30.08.2007'.

PERFORM BDC_FIELD USING 'EBAN-DISPO'

'001'.

PERFORM BDC_FIELD USING 'EBAN-FRGDT'

'19.07.2007'.

PERFORM BDC_FIELD USING 'EBAN-WEBAZ'

'1'.

PERFORM BDC_FIELD USING 'EBAN-PREIS'

' 1.46'.

PERFORM BDC_FIELD USING 'EBAN-WAERS'

'USD'.

PERFORM BDC_FIELD USING 'EBAN-PEINH'

'1'.

PERFORM BDC_FIELD USING 'EBAN-REPOS'

'X'.

FINAL = ITAB-NUMBER.

PERFORM BDC_DYNPRO USING 'SAPMM06B' '0106'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RM06B-BNFPO'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BU'.

PERFORM BDC_TRANSACTION USING 'ME51'.

REFRESH BDCDATA.

ENDIF.

ENDLOOP.

PERFORM CLOSE_GROUP.

&----


*& Form GETDATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GETDATA .

CALL FUNCTION 'UPLOAD'

EXPORTING

CODEPAGE = ' '

FILENAME = ' '

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. " GETDATA.

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

3)

We have to Set the Resolution of Screen when we populate the Data to Table control.

We have to use the Attribute called DEFAULTSIZE in CTUPARAMS in this case.

while using CALL TRANSACTION ...we can declare a structure with type CTUPARAMS....and set the DEFAULT SIZE ....By doing so...the screen resolution becomes 10.no matter where u r executing the program.

And so we can write as....

CALL TRANSACTION 'VK11' OPTIONS FROM S_CTUPARAMS.

We can handle this in Session method also.

If you check the FM BDC_INSERT there is a parameter

CTUPARAMS LIKE CTU_PARAMS which can be used to fill the Default size.

********

For screen resolution use ctu_params, with default size

Data : f_option type ctu_params,

f_option-updmode = 'S'.

f_option-defsize = 'X'.

f_option-dismode = 'N'.

call transaction 'VA01' using bdcdata options from f_option messages into bdcerror.

CALL TRANSACTION tcode... OPTIONS FROM opt

... OPTIONS FROM opt

Effect

Allows you to control processing using the values of the componetns of the structure opt, which must have the ABAP Dictionary type CTU_PARAMS. The components have the following meanings:

DISMODE

Display mode (like the MODE addition)

UPDMODE

Update mode (like the UPDATE addition)

CATTMODE

CATT mode (controls a CATT)

CATT mode can have the following values:

' ' No CATT active

'N' CATT without single-screen control

'A' CATT with single-screen control

DEFSIZE

Use default window size

RACOMMIT

Do not end transaction at COMMIT WORK

NOBINPT

No batch input mode (that is, SY-BINPT = SPACE)

NOBIEND

No batch input mode after the end of BDC data.

The components DEFSIZE , RACOMMIT, NOBINPT, and NOBIEND always take the following values:

'X' Yes

' ' No

If you do not use the OPTIONS FROM addition, the following control parameter settings apply:

DISMODE

From addition MODE

UPDMODE

From addition UPDATE

CATTMODE

No CATT active

DEFSIZE

Do not use default window size

RACOMMIT

Successful end on COMMIT WORK

NOBINPT

Batch input mode active ( SY-BINPT = X

NOBIEND

Batch input mode remains active after the BDC data

Reward points if helpful.

Thanks

Naveen khan