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: 

Looping through BDC

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

Hi,

From you code i se ethat you are not populating the OKCODE for screens. Can you chec kthat and make the correction?

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.

  • OKCODE REQUIRED

PERFORM dynpro USING:

'X' 'SAPMKAL1' '0201'.

' ' 'RKAL1-ITERATIVE' ' ',

' ' 'T811C-KUMUFLAG' p_cumula,

' ' 'T811C-EDATE' p_edate.

  • OKCODE REQUIRED

Hope this helps.

ashish

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Seshu ,

Thanks for the help. Yes I am new to abap. Just started to work with it 4 weeks back. This is my first BDC program. I really appreciate all the help I get from here.

Problem is solved. Needed to add refresh statement as you suggested.

Thanks!