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 : Table Control : Identify Last Line

Former Member
0 Kudos

Hi Friends,

Please tell me how to identify that records are filled in table control and reached to the last line so that i can refresh the page for new sets of blank line.I want to upload TCode - MB1C .

Sonal

8 REPLIES 8

Former Member
0 Kudos

0 Kudos

Hi Ravi,

I checked this program , but where it is identifying the last line of a table control ???

Sonal

Former Member
0 Kudos

Hi Sonal

You can use this code for BDC.

It will give you fixed rows on your screen.

w_options-defsize = 'X'.

CALL TRANSACTION 'AS02' USING BDCDATA

OPTIONS FROM W_OPTIONS

MESSAGES INTO MESSTAB.

Best Regards

Naresh

0 Kudos

Naresh ,

Can you explore a bit this.

Sonal

0 Kudos

Sonal

If you use

w_options-defsize = 'X'.

while calling CALL TRANSACTION. Then table control rows will be fixed. either 10 or 15 like this. then you can check in "A" mode how many rows its showing. This way you can put a check if row is 10 or 15 you can do page down.

CALL TRANSACTION 'AS02' USING BDCDATA

OPTIONS FROM W_OPTIONS

MESSAGES INTO MESSTAB

Regards

Naresh

0 Kudos

Hi Naresh,

Can you please write the exact code if i want to fix no of rows to 12 .

Sonal

0 Kudos

Sonal

here is the code... But you can't fix the rows. it will be fixed automatically you can just check whats the no of rows.

  • Batchinputdata of single transaction

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  • messages of call transaction

DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

  • error session opened (' ' or 'X')

data: w_options like ctu_params,

w_bukrs type bukrs,

w_cont type kokrs value 'CO01',

w_vlcur(18),

row type i,

wa_msg(255),

count type i,

int_excel type ALSMEX_TABLINE occurs 0 with header line,

w_bdc02(10),

w_bdc04(10),

w_bdc06(10),

w_bdc08(10),

w_bdc10(10),

w_bdc07(10),

w_bdc11(10),

w_bdc12(10),

w_msl(18),

w_max(2) type n,

w_count(2) type n value 1,

w_layout type RKE_CFORM,

w_date like sy-datum.

data: begin of it_tab occurs 0,

prctr type prctr,"Profit Center

racct type racct,"Account no

vlcur type VLCUR_PCA,"Company Code Currency

fkber type fkber_pca,"Functional area

werks type werks_d,"Plant

matnr type GLPCA-MATNR,"Material

sgtxt type GLPCA-SGTXT,"Text

anln1 type GLPCA-ANLN1,"Asset No

anln2 type GLPCA-ANLN2,"Asset Sub number

msl type RPCAC80-msl,"Quantity

runit type RPCAC80-runit,"UOM

end of it_tab.

selection-screen begin of screen 100.

parameters: filename type RLGRAP-FILENAME obligatory ,

P_LAYOUT TYPE RKE_CFORM,

BUKRS TYPE BUKRS,

P_DATE TYPE BUDAT.

select-options: rows for row no-extension.

selection-screen end of screen 100.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.

*Getting File Name

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = filename.

initialization.

w_options-defsize = 'X'.

W_OPTIONS-DISMODE = 'N'.

W_OPTIONS-RACOMMIT = 'X'.

start-of-selection.

call screen 100.

*Converting Excel Sheet to internal Table

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = filename

I_BEGIN_COL = 1

I_BEGIN_ROW = rows-low

I_END_COL = 11

I_END_ROW = rows-high

TABLES

INTERN = int_excel

  • EXCEPTIONS

  • INCONSISTENT_PARAMETERS = 1

  • UPLOAD_OLE = 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.

*Converting Excel internal table to

loop at int_excel.

case int_excel-col.

when 1."Profit Center

it_tab-prctr = int_excel-value.

when 2."Account no

it_tab-racct = int_excel-value.

when 3."Company Code Currency

it_tab-vlcur = int_excel-value.

when 4."Quanitity

it_tab-msl = int_excel-value.

when 5."Functional area

it_tab-fkber = int_excel-value.

when 6."Plant

it_tab-werks = int_excel-value.

when 7. "Material

it_tab-matnr = int_excel-value.

when 8."Asset

it_tab-anln1 = int_excel-value.

when 9."Asset Subnumber

it_tab-anln2 = int_excel-value.

when 10."Text

it_tab-sgtxt = int_excel-value.

when 11."UOM

it_tab-runit = int_excel-value.

endcase.

at end of row.

append it_tab.

clear it_tab.

endat.

endloop.

set parameter id 'CAC' field w_cont.

set parameter id 'BUK' field bukrs.

write p_date to w_date.

perform bdc_dynpro using 'SAPLPCPP' '1000'.

perform bdc_field using 'BDC_CURSOR'

'RKB1S-FORM'.

perform bdc_field using 'BDC_OKCODE'

'=SPLN'.

perform bdc_field using 'RKB1S-FORM'

P_LAYOUT."'PCA01'.

perform bdc_field using 'RPCAP-DOCTY'

'A0'.

perform bdc_field using 'RPCAA-BUDAT'

w_date.

perform bdc_dynpro using 'SAPLKPP0' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=CZUR'.

perform bdc_dynpro using 'SAPLPCPP' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=SPLN'.

perform bdc_field using 'RPCAA-BUDAT'

w_date.

perform bdc_dynpro using 'SAPLKPP0' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=CSUB'.

if p_layout = 'PCA03'.

perform bdc_dynpro using 'SAPLKPP2' '0106'.

perform bdc_field using 'BDC_OKCODE'

'=SACD'.

else.

perform bdc_dynpro using 'SAPLKPP2' '0103'.

perform bdc_field using 'BDC_OKCODE'

'=SACD'.

endif.

loop at it_tab.

write it_tab-vlcur to w_vlcur.

write it_tab-msl to w_msl.

concatenate 'BDC02(' w_count ')' into w_bdc02.

concatenate 'BDC04(' w_count ')' into w_bdc04.

concatenate 'BDC06(' w_count ')' into w_bdc06.

concatenate 'BDC07(' w_count ')' into w_bdc07.

concatenate 'BDC08(' w_count ')' into w_bdc08.

concatenate 'BDC10(' w_count ')' into w_bdc10.

concatenate 'BDC11(' w_count ')' into w_bdc11.

concatenate 'BDC12(' w_count ')' into w_bdc12.

if p_layout = 'PCA03'.

perform bdc_dynpro using 'SAPLKPP2' '0106'.

else.

perform bdc_dynpro using 'SAPLKPP2' '0103'.

endif.

perform bdc_field using 'BDC_CURSOR'

w_bdc06.

perform bdc_field using 'BDC_OKCODE'

'/00'.

if p_layout = 'PCA01'.

perform bdc_field using w_bdc02

it_tab-prctr."'1010101001'.

perform bdc_field using w_bdc04

it_tab-racct."'890003'.

perform bdc_field using w_bdc06

it_tab-runit.

perform bdc_field using w_bdc07

w_vlcur."'345'.

perform bdc_field using w_bdc08

w_msl.

elseif p_layout = 'PCA02' or p_layout = 'PCA03'.

perform bdc_field using w_bdc02

it_tab-prctr."'1010101001'.

perform bdc_field using w_bdc04

it_tab-fkber."Functional area

perform bdc_field using w_bdc06

it_tab-werks."Plant

perform bdc_field using w_bdc08

it_tab-racct.

perform bdc_field using w_bdc10

it_tab-runit.

perform bdc_field using w_bdc11

w_vlcur."'345'.

perform bdc_field using w_bdc12

w_msl.

endif.

if p_layout = 'PCA03'.

perform bdc_dynpro using 'SAPLKPP2' '0106'.

else.

perform bdc_dynpro using 'SAPLKPP2' '0103'.

endif.

perform bdc_field using 'BDC_CURSOR'

w_bdc02.

perform bdc_field using 'BDC_OKCODE'

'=SACD'.

perform bdc_dynpro using 'SAPLPCAD' '0001'.

perform bdc_field using 'BDC_OKCODE'

'=SADL'.

perform bdc_field using 'GLPCA-SGTXT'

it_tab-sgtxt.

perform bdc_dynpro using 'SAPLPCAD' '0001'.

perform bdc_field using 'BDC_OKCODE'

'=SADI'.

perform bdc_field using 'GLPCA-SGTXT'

it_tab-sgtxt.

perform bdc_field using 'BDC_CURSOR'

'GLPCA-REP_MATNR'.

if p_layout = 'PCA01'.

perform bdc_field using 'GLPCA-WERKS'

it_tab-werks.

endif.

perform bdc_field using 'GLPCA-MATNR'

it_tab-matnr.

perform bdc_dynpro using 'SAPLPCAD' '0001'.

perform bdc_field using 'BDC_OKCODE'

'=SWTR'.

*perform bdc_field using 'GLPCA-SGTXT'

  • 'test'.

perform bdc_field using 'BDC_CURSOR'

'GLPCA-ANLN2'.

perform bdc_field using 'GLPCA-ANLN1'

it_tab-anln1.

perform bdc_field using 'GLPCA-ANLN2'

it_tab-anln2.

if p_layout = 'PCA03'.

w_max = 14.

else.

w_max = 15.

endif.

if w_count = w_max.

if p_layout = 'PCA03'.

perform bdc_dynpro using 'SAPLKPP2' '0106'.

else.

perform bdc_dynpro using 'SAPLKPP2' '0103'.

endif.

perform bdc_field using 'BDC_OKCODE'

'=CP+'.

if p_layout = 'PCA03'.

perform bdc_dynpro using 'SAPLKPP2' '0106'.

else.

perform bdc_dynpro using 'SAPLKPP2' '0103'.

endif.

perform bdc_field using 'BDC_OKCODE'

'=SACD'.

w_count = 0.

endif.

w_count = w_count + 1.

endloop.

if p_layout = 'PCA03'.

perform bdc_dynpro using 'SAPLKPP2' '0106'.

else.

perform bdc_dynpro using 'SAPLKPP2' '0103'.

endif.

perform bdc_field using 'BDC_OKCODE'

'=CBUC'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

perform bdc_dynpro using 'SAPLKPP0' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=CZUR'.

perform bdc_dynpro using 'SAPLPCPP' '1000'.

perform bdc_field using 'BDC_OKCODE'

'/ESZUR'.

CALL TRANSACTION '9KE0' USING BDCDATA

OPTIONS FROM W_OPTIONS

MESSAGES INTO MESSTAB.

SORT messtab.

delete adjacent duplicates from messtab.

loop at messtab.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = messtab-msgid

LANG = 'E'

NO = messtab-msgnr

V1 = messtab-msgv1

V2 = messtab-msgv2

V3 = messtab-msgv3

V4 = messtab-msgv4

IMPORTING

MSG = wa_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.

write :wa_msg.

clear: wa_msg.

endloop.

refresh:messtab,bdcdata.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDFORM.

Former Member
0 Kudos

Hi Sonal,

i understood the problem.

I came across the same situation and i have fixed it.

Your BDC is for transaction MB1C.

In transaction MB1C - screen 421 has a create button at the application menu.

When you enter a record in the first line item in this screen and when you click

'create' button,the items scroll up and the 2nd item scrolls to first position.

The OK-Code for the create button is 'NLE'.

Record the transaction MB1C by performing an action on 'Create' button and use the generated code.

It would help.

Thanks & regards,

Sreenivasulu P

Message was edited by:

P Sreenivasulu