Application Development and Automation 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: 
Read only

Table control

Former Member
0 Likes
487

Hi All,

While uploading data into VA01 how we can pass the values to table control?

is there any option to handle table control while doing recording or we have to do something in coding ?

can any body send me the related coding for this.

Thanks in advance

Rambabu.A

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
454

HI Ram,

While recording just enter 1 value in the table control. While coding u can take other loop for those perticular table control records. Take care while recording otherwise you may face some problems. Take the exmaple of XK01 code. It will help you. Hope this helps you. Reply for queries, shall post the updates.

Regards.

Kumar

3 REPLIES 3
Read only

Former Member
0 Likes
454

Hi

You have to handle this Table control population through coding only

Loop the Header Itab

under this loop the Item ITAB with key

populate the fields line by line with index in the table control and handle the pageup and downs

see the sample code for ME51 Tcode where in population of table control is handled

REPORT zmm_pr_upload_mat

NO STANDARD PAGE HEADING

LINE-SIZE 255.

  • Standard Include for Selection Screen

INCLUDE bdcrecx1.

  • Internal Table for Upload Data

DATA: BEGIN OF i_pr OCCURS 0,

  • Header Screen

sno(3), " SNo

bsart(004), " PR Type

epstp(001), " Item Category

knttp(001), " Account Assignment

eeind(010), " Delivery Date

  • lpein(001), " Category of Del Date

werks(004), " Plant

lgort(004), " Storage Location

ekgrp(003), " Purchasing Group

matkl(009), " Material Group

bednr(010), " Tracking No

afnam(012), " Requisitioner

  • Item Details

matnr(018), " Material No

menge(017), " Quantity

  • badat(010),

  • frgdt(010),

preis(014), " Valuation Price

  • waers(005), " Currency

  • peinh(005),

  • wepos(001),

  • repos(001),

sakto(010), " GL Account

kostl(010), " Cost Center

  • bnfpo(005),

END OF i_pr.

  • Internal Table for header Data

DATA: BEGIN OF it_header OCCURS 0,

sno(3), " SNo

bsart(004), " PR Type

epstp(001), " Item Category

knttp(001), " Account Assignment

eeind(010), " Delivery Date

werks(004), " Plant

lgort(004), " Storage Location

ekgrp(003), " Purchasing Group

matkl(009), " Material Group

bednr(010), " Tracking No

afnam(012), " Requisitioner

END OF it_header.

  • Internal Table for Item Data

DATA: BEGIN OF it_item OCCURS 0,

sno(3), " SNo

matnr(018), " Material No

menge(017), " Quantity

preis(014), " Valuation Price

sakto(010), " GL Account

kostl(010), " Cost Center

END OF it_item.

  • Data Variables & Constants

CONSTANTS : c_x VALUE 'X'. " Flag

DATA : v_l(2), " Counter

v_rowno(5), " Row No

v_2(2), " Counter

v_rows LIKE sy-srows, " Rows in TC

v_field(45). " String

  • Parameters

PARAMETERS: p_file LIKE ibipparms-path. " Filename

  • At selection-screen on Value Request for file Name

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  • Get the F4 Values for the File

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

IMPORTING

file_name = p_file.

  • Start of Selection

START-OF-SELECTION.

  • Open the BDC Session

PERFORM open_group.

  • Upload the File into internal Table

CALL FUNCTION 'UPLOAD'

EXPORTING

filename = p_file

filetype = 'DAT'

TABLES

data_tab = i_pr

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.

SORT i_pr BY sno.

LOOP AT i_pr.

MOVE-CORRESPONDING i_pr TO it_item.

APPEND it_item.

CLEAR it_item.

AT END OF sno.

READ TABLE i_pr INDEX sy-tabix.

MOVE-CORRESPONDING i_pr TO it_header.

APPEND it_header.

CLEAR it_header.

ENDAT.

ENDLOOP.

SORT it_header BY sno.

SORT it_item BY sno.

v_rows = sy-srows - 6.

  • Upload the Data from Internal Table

LOOP AT it_header.

  • Header Data

PERFORM bdc_dynpro USING 'SAPMM06B' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EBAN-BEDNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'EBAN-BSART'

it_header-bsart.

PERFORM bdc_field USING 'RM06B-EPSTP'

it_header-epstp.

PERFORM bdc_field USING 'EBAN-KNTTP'

it_header-knttp.

PERFORM bdc_field USING 'RM06B-EEIND'

it_header-eeind.

  • PERFORM bdc_field USING 'RM06B-LPEIN'

  • it_header-lpein.

PERFORM bdc_field USING 'EBAN-WERKS'

it_header-werks.

PERFORM bdc_field USING 'EBAN-LGORT'

it_header-lgort.

PERFORM bdc_field USING 'EBAN-EKGRP'

it_header-ekgrp.

PERFORM bdc_field USING 'EBAN-MATKL'

it_header-matkl.

PERFORM bdc_field USING 'EBAN-BEDNR'

it_header-bednr.

PERFORM bdc_field USING 'EBAN-AFNAM'

it_header-afnam.

  • Item Details

v_l = 0.

  • To add no. of rows

v_2 = 0 .

  • As the screen is showing 13 rows defaulted to 130

v_rowno = 130 .

LOOP AT it_item WHERE sno = it_header-sno.

v_l = v_l + 1.

IF v_l = 14 .

IF v_2 = 12 .

v_2 = 12 .

v_l = 2 .

  • From second time onwards it is displaying 12 rows only

v_rowno = v_rowno + 120 .

PERFORM bdc_dynpro USING 'SAPMM06B' '0106'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM06B-BNFPO'.

PERFORM bdc_field USING 'RM06B-BNFPO'

v_rowno.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

ELSE.

  • V_2 initialized to 12 for second screen purpose

v_2 = 12 .

v_l = 2 .

PERFORM bdc_dynpro USING 'SAPMM06B' '0106'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM06B-BNFPO'.

PERFORM bdc_field USING 'RM06B-BNFPO'

v_rowno .

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

ENDIF.

ENDIF.

PERFORM bdc_dynpro USING 'SAPMM06B' '0106'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

CLEAR v_field.

CONCATENATE 'EBAN-MATNR(' v_l ')' INTO v_field.

PERFORM bdc_field USING v_field it_item-matnr.

CLEAR v_field.

CONCATENATE 'EBAN-MENGE(' v_l ')' INTO v_field.

PERFORM bdc_field USING v_field it_item-menge.

PERFORM bdc_dynpro USING 'SAPMM06B' '0102'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EBAN-PREIS'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'EBAN-PREIS'

it_item-preis.

PERFORM bdc_dynpro USING 'SAPMM06B' '0505'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EBKN-SAKTO'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_field USING 'EBKN-SAKTO'

it_item-sakto.

  • Cost Center

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_CURSOR'

'COBL-KOSTL'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_field USING 'COBL-KOSTL'

it_item-kostl.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

ENDLOOP.

PERFORM bdc_dynpro USING 'SAPMM06B' '0106'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM06B-BNFPO'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

  • Call The Transaction

PERFORM bdc_transaction USING 'ME51'.

ENDLOOP.

  • Close the BDC Session

PERFORM close_group.

reward if sueful

regards

Anji

Read only

Former Member
0 Likes
454

Ram,

See the below code how to loop the lines for each header item with screen resolution.

report ZCUST_XD01_BDC

no standard page heading line-size 255.

TYPES: BEGIN OF TY_REC,

BUKRS LIKE RF02D-BUKRS,

VKORG LIKE RF02D-VKORG,

KUNNR LIKE RF02D-KUNNR,

NAME1 LIKE KNA1-NAME1,

ANRED LIKE KNA1-ANRED,

SORTL LIKE KNA1-SORTL,

ORT01 LIKE KNA1-ORT01,

LAND1 LIKE KNA1-LAND1,

SPRAS LIKE KNA1-SPRAS,

PSTLZ LIKE KNA1-PSTLZ,

END OF TY_REC.

TYPES: BEGIN OF TY_BANK,

KUNNR LIKE RF02D-KUNNR,

BANKS LIKE KNBK-BANKS,

BANKL LIKE KNBK-BANKL,

BANKN LIKE KNBK-BANKN,

KOINH LIKE KNBK-KOINH,

BANKA LIKE BNKA-BANKA,

PROVZ LIKE BNKA-PROVZ,

ORT01 LIKE BNKA-ORT01,

END OF TY_BANK.

DATA: IT_REC TYPE STANDARD TABLE OF TY_REC WITH HEADER LINE,

IT_BA TYPE STANDARD TABLE OF TY_BANK WITH HEADER LINE.

DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

I_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,

G_PARAMS LIKE CTU_PARAMS.

DATA: BANKS(14) TYPE C VALUE 'KNBK-BANKS(&1)',

BANKL(14) TYPE C VALUE 'KNBK-BANKL(&1)',

BANKN(14) TYPE C VALUE 'KNBK-BANKN(&1)',

KOINH(14) TYPE C VALUE 'KNBK-KOINH(&1)'.

  • BANKL(14) TYPE C VALUE 'KNBK-BANKL(&1)',

  • BANKN(14) TYPE C VALUE 'KNBK-BANKN(&1)'.

DATA: C(2) VALUE '&1'.

IT_REC-BUKRS = '1000'.

  • IT_REC-VKORG = '1000'.

IT_REC-KUNNR = '6998'.

IT_REC-ANRED = 'M/S'.

IT_REC-NAME1 = 'GOPAL ENTERPRISES'.

IT_REC-SORTL = 'GOPS'.

IT_REC-ORT01 = 'BANGALORE'.

IT_REC-LAND1 = 'IN'.

IT_REC-SPRAS = 'EN'.

IT_REC-PSTLZ = '560036'.

APPEND IT_REC.

IT_BA-KUNNR = '6998'.

IT_BA-BANKS = 'IN'.

IT_BA-BANKL = '2001'.

IT_BA-BANKN = '342567'.

IT_BA-KOINH = 'GOPS'.

IT_BA-BANKA = 'TEST1'.

IT_BA-PROVZ = 'IN'.

IT_BA-ORT01 = 'BANGALORE'.

APPEND IT_BA.

CLEAR IT_BA.

IT_BA-KUNNR = '6998'.

IT_BA-BANKS = 'IN'.

IT_BA-BANKL = '2002'.

IT_BA-BANKN = '342568'.

IT_BA-KOINH = 'GOPS'.

IT_BA-BANKA = 'TEST2'.

IT_BA-PROVZ = 'IN'.

IT_BA-ORT01 = 'BANGALORE'.

APPEND IT_BA.

CLEAR IT_BA.

IT_BA-KUNNR = '6998'.

IT_BA-BANKS = 'IN'.

IT_BA-BANKL = '2003'.

IT_BA-BANKN = '342569'.

IT_BA-KOINH = 'GOPS'.

IT_BA-BANKA = 'TEST3'.

IT_BA-PROVZ = 'IN'.

IT_BA-ORT01 = 'BANGALORE'.

APPEND IT_BA.

G_PARAMS-DISMODE = 'A'.

G_PARAMS-UPDMODE = 'S'.

G_PARAMS-DEFSIZE = 'X'.

start-of-selection.

LOOP AT IT_REC.

REFRESH I_BDCDATA.

CLEAR I_BDCDATA.

perform bdc_dynpro using 'SAPMF02D' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-KTOKD'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-KUNNR'

it_rec-kunnr.

perform bdc_field using 'RF02D-KTOKD'

'Z003'.

perform bdc_dynpro using 'SAPMF02D' '0110'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KNA1-ANRED'

it_rec-anred.

perform bdc_field using 'KNA1-NAME1'

it_rec-name1.

perform bdc_field using 'KNA1-SORTL'

it_rec-sortl.

perform bdc_field using 'KNA1-ORT01'

it_rec-ort01.

perform bdc_field using 'KNA1-PSTLZ'

'560066'.

perform bdc_field using 'KNA1-LAND1'

'in'.

perform bdc_field using 'KNA1-SPRAS'

it_rec-spras.

perform bdc_dynpro using 'SAPMF02D' '0120'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-STCEG'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02D' '0130'.

perform bdc_field using 'BDC_CURSOR'

'KNBK-KOINH(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

loop at it_ba where kunnr = it_rec-kunnr.

perform bdc_field using 'KNBK-BANKS(01)'

it_ba-banks.

perform bdc_field using 'KNBK-BANKL(01)'

it_ba-bankl.

perform bdc_field using 'KNBK-BANKN(01)'

it_ba-bankn.

perform bdc_field using 'KNBK-KOINH(01)'

it_ba-koinh.

perform bdc_dynpro using 'SAPLBANK' '0100'.

perform bdc_field using 'BDC_CURSOR'

'BNKA-BRNCH'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'BNKA-BANKA'

it_ba-banka.

perform bdc_field using 'BNKA-PROVZ'

it_ba-provz.

perform bdc_field using 'BNKA-ORT01'

it_ba-ort01.

perform bdc_field using 'BNKA-BRNCH'

'Bangalore'.

perform bdc_dynpro using 'SAPLBANK' '0100'.

perform bdc_field using 'BNKA-BANKA'

'Test Bank'.

perform bdc_field using 'BNKA-PROVZ'

'10'.

perform bdc_field using 'BNKA-ORT01'

'Bangalore'.

perform bdc_field using 'BNKA-BRNCH'

'Bangalore'.

endloop.

perform bdc_dynpro using 'SAPMF02D' '0130'.

perform bdc_field using 'BDC_CURSOR'

'KNBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

CALL TRANSACTION 'XD01' USING I_BDCDATA

OPTIONS FROM G_PARAMS MESSAGES INTO I_MESSTAB.

  • CALL TRANSACTION 'XD01' USING I_BDCDATA

  • MODE 'A'

  • UPDATE 'S'

  • MESSAGES INTO I_MESSTAB.

ENDLOOP.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR I_BDCDATA.

I_BDCDATA-PROGRAM = PROGRAM.

I_BDCDATA-DYNPRO = DYNPRO.

I_BDCDATA-DYNBEGIN = 'X'.

APPEND I_BDCDATA.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

  • IF FVAL <> NODATA.

CLEAR I_BDCDATA.

I_BDCDATA-FNAM = FNAM.

I_BDCDATA-FVAL = FVAL.

APPEND I_BDCDATA.

  • ENDIF.

ENDFORM. "BDC_FIELD.

Don't forget to reward if useful

Read only

Former Member
0 Likes
455

HI Ram,

While recording just enter 1 value in the table control. While coding u can take other loop for those perticular table control records. Take care while recording otherwise you may face some problems. Take the exmaple of XK01 code. It will help you. Hope this helps you. Reply for queries, shall post the updates.

Regards.

Kumar