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: 

page up in bdc

Former Member
0 Kudos

hi ABAPER

I am applying these codes,but i am unable to fill up the data in next page in bdc table control, so please help me.

data:begin of itab occurs 0,

lifnr(16),

bukrs(4),

d0610(01),

witht(02),

WT_WITHCD(02),

WT_SUBJCT(01),

text40(40),

end of itab.

data : lifnr like lfbw-lifnr.

data : begin of itab2 occurs 0,

WITHT like LFBW-WITHT,

end of itab2.

DATA BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

*----


*

  • SELECTION SCREEN DECLARATIONS

*----


*

selection-screen: begin of block b1 with frame title text-001.

parameters : p_file like rlgrap-filename obligatory.

  • V_ERROR like IBIPPARMS-PATH.

parameters: begcol type i default 1 no-display,

begrow type i default 1 no-display,

endcol type i default 100 no-display,

endrow type i default 32000 no-display.

selection-screen: end of block b1.

*-- Internal table to store excel data

data: begin of it_excel_data occurs 0.

include structure alsmex_tabline.

data: end of it_excel_data.

data: begin of it_excel_data1 occurs 0.

include structure alsmex_tabline.

data: end of it_excel_data1.

data: begin of it_col occurs 0,

col like alsmex_tabline-col,

size type i.

data: end of it_col.

data: begin of it_fieldnames occurs 3,

title(60),

table(6),

field(10),

kz(1),

end of it_fieldnames.

data: begin of it_final occurs 0,

value_0001(50),

value_0002(50),

value_0003(50),

value_0004(50),

value_0005(50),

value_0006(50),

value_0007(50),

  • value_0008(50),

  • value_0009(50),

  • value_0010(50),

  • value_0011(50),

  • value_0012(50),

end of it_final.

*----


*

  • DATA DECLARATIONS

*----


*

data: v_lines type i, "Total no of IT_CONDNs

v_bdc_total_recs type i, "no.of IT_CONDNs inserted in BDC

v_color type c, "Toggle color

v_open_error type c, "BDC Open Error

v_file_not_read type c, "File not read

v_matnr like mara-matnr, "Matnr

v_bdc_open, "To indicate if BDC session-

"-is open or closed.

zwlen type i,

zwlines type i,

tind(4) type n,

zwfeld(19) type c.

  • DATA BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  • DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

  • DATA : it_error like it_condn occurs 0 with header line.

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

*

  • Internal table to find the error from the legacy data

*

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

*

DATA : begin of it_erfind occurs 0,

INDEX(10), "Index for error file

er_message(100), "For Error Message

end of it_erfind.

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

*

  • Variables declaration

*

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

*

DATA : g_message(200),

time(10),

date(10),

v_error like IBIPPARMS-PATH.

date = sy-datum.

time = sy-uzeit.

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

*

  • Initialization

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

*

initialization.

  • Generating Error file name with date and time.

  • perform make_file_name.

*----


*

  • START-OF-SELECTION.

*----


*

start-of-selection.

*-- Read file from presentation server and store in an internal table

perform get_data.

*-- Process Internal table

perform process_itab.

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

*

**

  • FIELD SYMBOLS

*

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

*

field-symbols: <fs1>.

  • DATA BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA: flag(1) TYPE C,

v_count TYPE n VALUE 1,

v_indx type c,

fnam(20),v_mod type c,

pagno like sy-pagno,

max type i.

LOOP AT itAB.

REFRESH BDCDATA.

at new lifnr.

flag = 'X'.

endat.

if flag = 'X'.

PERFORM BDC_TAX.

clear flag.

CALL TRANSACTION 'XK02' USING BDCDATA MODE 'A' UPDATE 'S'.

endif.

ENDLOOP.

at selection-screen ON VALUE-REQUEST FOR p_file .

PERFORM GETFILENAME.

*start-of-selection.

*include bdcrecx1.

*

*start-of-selection.

*

*perform open_group.

*&----


*

*& Form get_data

*&----


*

form get_data.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = p_file

i_begin_col = begcol

i_begin_row = begrow

i_end_col = endcol

i_end_row = endrow

TABLES

intern = it_excel_data

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

others = 3.

endform. " get_data

*&----


*

*& Form process_itab

*&----


*

form process_itab .

loop at it_excel_data.

it_excel_data1 = it_excel_data.

clear it_excel_data1-row.

append it_excel_data1.

endloop.

sort it_excel_data1 by col.

loop at it_excel_data1.

at new col.

it_col-col = it_excel_data1-col.

append it_col.

endat.

zwlen = strlen( it_excel_data1-value ).

read table it_col with key col = it_excel_data1-col.

if sy-subrc eq 0.

if zwlen > it_col-size.

it_col-size = zwlen.

  • Internal Table, Current Row Index

modify it_col index sy-tabix.

endif.

endif.

endloop.

describe table it_col lines zwlines.

sort it_excel_data by row col.

loop at it_excel_data.

it_fieldnames-title = it_excel_data-value.

append it_fieldnames.

at end of row.

exit.

endat.

endloop.

sort it_excel_data by row col.

loop at it_excel_data.

tind = it_excel_data-col.

concatenate 'IT_FINAL-VALUE_' tind into zwfeld.

assign (zwfeld) to <fs1>.

<fs1> = it_excel_data-value.

at end of row.

append it_final.

clear it_final.

endat.

endloop.

loop at it_final.

if sy-tabix > 1.

  • it_condn-index = it_final-value_0001.

itAB-lifnR = it_final-value_0001.

itAB-bukrs = it_final-value_0002.

itAB-d0610 = it_final-value_0003.

itab-WITHT = it_final-value_0004.

itab-wt_subjct = it_final-value_0005.

itab-WT_WITHCD = it_final-value_0006.

itab-text40 = it_final-value_0007.

  • it_condn-MATNR = it_final-value_0009.

  • it_condn-KBETR = it_final-value_0010.

  • it_condn-DATAB = it_final-value_0011.

  • it_condn-DATBI = it_final-value_0012.

  • append it_condn.

append itab.

  • append it_dummy.

  • append it_dummy.

  • clear it_condn.

clear itab.

endif.

endloop.

  • describe table it_condn lines v_lines.

describe table itab lines v_lines.

endform. " process_itab

*start-of-selection.

*data:lv_tabix type i.

*loop at itab.

FORM BDC_TAX.

*LOOP AT ITAB.

*lv_tabix = sy-tabix.

*

*AT NEW LIFNR.

*read table itab index lv_tabix.

*clear V_INDX.

*REFRESH BDCDATA.

*CLEAR: BDCDATA,BDCDATA[].

perform bdc_dynpro using 'SAPMF02K' '0101'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-D0610'.

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-D0610'

'X'.

*perform bdc_dynpro using 'SAPMF02K' '0610'.

*perform bdc_field using 'BDC_OKCODE'

  • '=P+'.

*perform bdc_field using 'BDC_CURSOR'

  • 'LFB1-QLAND'.

*perform bdc_field using 'LFB1-QLAND'

  • 'IN'.

perform bdc_dynpro using 'SAPMF02K' '0610'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'LFBW-WT_SUBJCT'.

perform bdc_field using 'LFB1-QLAND'

'IN'.

*endat.

clear v_lines.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = itab-lifnr

IMPORTING

OUTPUT = lfbw-lifnr.

  • .

select WITHT

from LFBW

into table itab2 where lifnr = lfbw-lifnr.

  • and bukrs = itab-bukrs.

  • if v_lines < 6.

  • if sy-subrc = 0.

  • describe table itab2 lines v_lines.

describe table itab2 lines sy-tabix.

  • if v_lines < 6.

if sy-tabix < 6.

sy-tabix = sy-tabix + 1.

  • v_lines = v_lines + 1.

  • endif.

*ELSEIF V_LINES = 6.

*v_lines = v_lines + 1.

*else.

*v_mod = v_lines mod 6.

*if v_mod = 0.

*v_lines = v_lines + 1.

*else.

*v_lines = v_mod + 1.

*endif.

*endif.

  • MOVE v_lines TO V_INDX.

*endif.

  • MOVE v_lines TO V_INDX.

MOVE sy-tabix TO V_INDX.

LOOP AT itab where lifnr = itab-lifnr.

CONCATENATE 'LFBW-WITHT(' v_indx ')' INTO FNAM.

CONDENSE FNAM NO-GAPS.

perform bdc_field using fnam

ITAB-WITHT.

CONCATENATE 'LFBW-WT_SUBJCT(' v_indx ')' INTO FNAM.

CONDENSE FNAM NO-GAPS.

perform bdc_field using FNAM

ITAB-WT_SUBJCT.

CONCATENATE 'LFBW-WT_WITHCD(' v_indx ')' INTO FNAM.

CONDENSE FNAM NO-GAPS.

perform bdc_field using FNAM

ITAB-WT_WITHCD.

CONCATENATE 'T059U-TEXT40(' v_indx ')' INTO FNAM.

CONDENSE FNAM NO-GAPS.

perform bdc_field using FNAM

ITAB-TEXT40.

v_indx = v_indx + 1.

IF V_INDX > 6.

EXIT.

ENDIF.

*perform bdc_dynpro using 'SAPMF02K' '0610'.

*perform bdc_field using 'BDC_OKCODE'

  • '=UPDA'.

  • perform bdc_dynpro using 'SAPMF02K' '0610'.

  • perform bdc_field using 'BDC_OKCODE'

  • '=SICH'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-QLAND'.

perform bdc_field using 'LFB1-QLAND'

'IN'.

ENDLOOP.

ELSEIF V_INDX = 6.

v_indx = v_indx + 1.

MOVE v_INDX TO V_INDX.

**endif.

LOOP AT itab where lifnr = itab-lifnr.

  • perform bdc_dynpro using 'SAPMF02K' '0610'.

*perform bdc_field using 'BDC_OKCODE'

  • '=P+'.

*perform bdc_field using 'BDC_CURSOR'

  • 'LFB1-QLAND'.

*perform bdc_field using 'LFB1-QLAND'

  • 'IN'.

CONCATENATE 'LFBW-WITHT(' v_indx ')' INTO FNAM.

perform bdc_field using fnam

ITAB-WITHT.

CONCATENATE 'LFBW-WT_SUBJCT(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-WT_SUBJCT.

CONCATENATE 'LFBW-WT_WITHCD(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-WT_WITHCD.

CONCATENATE 'T059U-TEXT40(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-TEXT40.

v_indx = v_indx + 1.

perform bdc_dynpro using 'SAPMF02K' '0610'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-QLAND'.

perform bdc_field using 'LFB1-QLAND'

'IN'.

perform bdc_dynpro using 'SAPMF02K' '0610'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-QLAND'.

perform bdc_field using 'LFB1-QLAND'

'IN'.

ENDLOOP.

else.

**describe table itab2 lines v_lines.

v_mod = v_lines mod 6.

if v_mod = 0.

v_lines = v_lines + 1.

MOVE v_lines TO V_INDX.

LOOP AT itab where lifnr = itab-lifnr.

perform bdc_dynpro using 'SAPMF02K' '0610'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-QLAND'.

perform bdc_field using 'LFB1-QLAND'

'IN'.

CONCATENATE 'LFBW-WITHT(' v_indx ')' INTO FNAM.

perform bdc_field using fnam

ITAB-WITHT.

CONCATENATE 'LFBW-WT_SUBJCT(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-WT_SUBJCT.

CONCATENATE 'LFBW-WT_WITHCD(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-WT_WITHCD.

CONCATENATE 'T059U-TEXT40(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-TEXT40.

v_indx = v_indx + 1.

perform bdc_dynpro using 'SAPMF02K' '0610'.

perform bdc_field using 'BDC_OKCODE'

'=PP+'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-QLAND'.

perform bdc_field using 'LFB1-QLAND'

'IN'.

  • perform bdc_dynpro using 'SAPMF02K' '0610'.

  • perform bdc_field using 'BDC_OKCODE'

  • '=SICH'.

  • perform bdc_field using 'BDC_CURSOR'

  • 'LFB1-QLAND'.

  • perform bdc_field using 'LFB1-QLAND'

  • 'IN'.

ENDLOOP.

else.

v_lines = v_mod + 1.

MOVE v_lines TO V_INDX.

LOOP AT itab where lifnr = itab-lifnr.

perform bdc_dynpro using 'SAPMF02K' '0610'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-QLAND'.

perform bdc_field using 'LFB1-QLAND'

'IN'.

CONCATENATE 'LFBW-WITHT(' v_indx ')' INTO FNAM.

perform bdc_field using fnam

ITAB-WITHT.

CONCATENATE 'LFBW-WT_SUBJCT(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-WT_SUBJCT.

CONCATENATE 'LFBW-WT_WITHCD(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-WT_WITHCD.

CONCATENATE 'T059U-TEXT40(' v_indx ')' INTO FNAM.

perform bdc_field using FNAM

ITAB-TEXT40.

v_indx = v_indx + 1.

  • perform bdc_dynpro using 'SAPMF02K' '0610'.

  • perform bdc_field using 'BDC_OKCODE'

  • '=P+'.

  • perform bdc_field using 'BDC_CURSOR'

  • 'LFB1-QLAND'.

  • perform bdc_field using 'LFB1-QLAND'

  • 'IN'.

  • perform bdc_dynpro using 'SAPMF02K' '0610'.

  • perform bdc_field using 'BDC_OKCODE'

  • '=SICH'.

  • perform bdc_field using 'BDC_CURSOR'

  • 'LFB1-QLAND'.

  • perform bdc_field using 'LFB1-QLAND'

  • 'IN'.

ENDLOOP.

endif.

  • endif.

ENDIF.

  • MOVE v_lines TO V_INDX.

*endif.

*

  • endif.

perform bdc_dynpro using 'SAPMF02K' '0610'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

*perform bdc_field using 'BDC_CURSOR'

  • 'LFB1-QLAND'.

*perform bdc_field using 'LFB1-QLAND'

  • 'IN'.

  • CALL TRANSACTION 'XK02' USING BDCDATA MODE 'A' UPDATE 'S'.

clear itab2.

refresh itab2.

ENDform. "BDC_TAX

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> SPACE.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM. "BDC_FIELD

&----


*& Form GETFILENAME

&----


  • text

----


FORM GETFILENAME.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_FILE.

ENDFORM. "GETFILENAME

1 REPLY 1

Former Member
0 Kudos

Hello ,

in batch , try to use ok_code '/06' to position on a line.

to help you, you can look at standard program RFBIKR00 :

subroutine RFBIKF00

...

LOOP AT XBLFBW.

CLEAR XDYTR.

PERFORM OKCODE_POSZ.

PERFORM D2610_FUELLEN.

PERFORM DYNPRO_FUELLEN USING DYNTAB-DYNNR.

PERFORM CURSOR_SETZEN_0610.

IF XBLFBW-XDELE = 'X'.

PERFORM OKCODE_F14.

PERFORM DYNPRO_BEGIN USING REP_NAME_K DYNTAB-DYNNR.

XDYTR = 'X'.

ENDIF.

PERFORM LFBW_BEARBEITEN.

ENDLOOP.

Regards and good luck