Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Looping through BDC

Hello All,

Pls let me know how to update a field with new value which is being setup using BDC. I mean, I am looping through an internal table. In this loop I am calling dynpro to setup some screen fields. The problem arrives on the second iteration. The field I am trying to setup does not show me the new field value. It retains its first value which is my first row in the internal table. Here is my code to help you understand my issue:

DATA: bdc_tab LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF struct2,

field_a(8) TYPE c,

END OF struct2.

DATA itab3 LIKE struct2 OCCURS 10 WITH HEADER LINE.

LOOP AT itab3. "itab3 contains values like A1201, B4567, etc. these values were read from a csv file, and sotred in itab3.

PERFORM dynpro USING:

'X' 'SAPMKAL1' '0104'.

' ' 'RKAL1-RLDNR' p_ledger,

' ' 'RKAL1-GLCYC' itab3-field_a,

' ' 'RKAL1-RGLCYC' itab3-field_a,

' ' 'T811C-SDATE' p_sdate,

' ' 'RKAL1-RRLDNR' p_ledgr2,

' ' 'RKAL1-RSDATE' p_sdate2.

PERFORM dynpro USING:

'X' 'SAPMKAL1' '0201'.

' ' 'RKAL1-ITERATIVE' ' ',

' ' 'T811C-KUMUFLAG' p_cumula,

' ' 'T811C-EDATE' p_edate.

  • WRITE :/ 'bdc_tab value before transaction call =', bdc_tab-fval.

  • WRITE :/ 'itab3 value before transaction call =', itab3-field_a.

CALL TRANSACTION 'GA31' USING bdc_tab.

ENDLOOP.

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

FORM dynpro USING dynbegin name value.

IF dynbegin = 'X'.

CLEAR bdc_tab.

MOVE: name TO bdc_tab-program,

value TO bdc_tab-dynpro,

'X' TO bdc_tab-dynbegin.

APPEND bdc_tab.

ELSE.

CLEAR bdc_tab.

MOVE: name TO bdc_tab-fnam,

value TO bdc_tab-fval.

APPEND bdc_tab.

ENDIF.

ENDFORM.

I verfied that the bdc table does contain the right value. But I am not able to see them on the screen fields...only first value stays in the fields (RKAL1-GLCYC, RKAL1-RGLCYC).

Any input would be greatly appreciated. Thanks alot for your help.

Tags:
Former Member
Former Member replied

There are plenty of mistakes in your code

LOOP AT itab3. "itab3 contains values like A1201, B4567, etc. these values were read from a csv file, and sotred in itab3.

PERFORM dynpro USING:

'X' 'SAPMKAL1' '0104'.

' ' 'RKAL1-RLDNR' p_ledger,

' ' 'RKAL1-GLCYC' itab3-field_a,

' ' 'RKAL1-RGLCYC' itab3-field_a,

' ' 'T811C-SDATE' p_sdate,

' ' 'RKAL1-RRLDNR' p_ledgr2,

' ' 'RKAL1-RSDATE' p_sdate2.

PERFORM dynpro USING:

'X' 'SAPMKAL1' '0201'.

' ' 'RKAL1-ITERATIVE' ' ',

' ' 'T811C-KUMUFLAG' p_cumula,

' ' 'T811C-EDATE' p_edate.

  • WRITE :/ 'bdc_tab value before transaction call =', bdc_tab-fval.

  • WRITE :/ 'itab3 value before transaction call =', itab3-field_a.

CALL TRANSACTION 'GA31' USING bdc_tab

<b> Mode 'A'.</b>

<b>refresh bdc_tab.</b>

ENDLOOP.

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

FORM dynpro USING dynbegin name value.

IF dynbegin = 'X'.

CLEAR bdc_tab.

MOVE: name TO bdc_tab-program,

value TO bdc_tab-dynpro,

'X' TO bdc_tab-dynbegin.

APPEND bdc_tab.

ELSE.

CLEAR bdc_tab.

MOVE: name TO bdc_tab-fnam,

value TO bdc_tab-fval.

APPEND bdc_tab.

ENDIF.

ENDFORM.

use refresh bdc_tab after call transaction.

Thanks

Seshu

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question