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

ITAB IS not Modifying.

Former Member
0 Likes
560

Hi All,

Please look at my code.I am trying to update main_itab with wf_ind field. Its pulling correct data in wfa_itab.

But its not modifying main_itab.

Any suggestion will be help ful for me.

DATA: Begin of WFA_itab occurs 0,

reference like zest1940_sfa_ptf-reference,

wf_ind like zest1940_sfa_ptf-name,

end of WFA_itab.

select reference name from zest1940_sfa_ptf into table WFA_itab

FOR all entries in main_itab where

reference = main_itab-reference and

partn_func EQ 'AP' .

loop at WFA_itab.

Modify main_itab transporting wf_ind where

reference EQ WFA_itab-reference.

append main_itab.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
540

Hi,

Check this code.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DATA: BEGIN OF wfa_itab OCCURS 0,
        reference LIKE zest1940_sfa_ptf-reference,
        wf_ind LIKE zest1940_sfa_ptf-name,
END OF wfa_itab.

DATA: l_index LIKE sy-tabix.   *" New variable inserted

SELECT
      reference
      name FROM zest1940_sfa_ptf
      INTO TABLE wfa_itab
      FOR ALL ENTRIES IN main_itab
      WHERE reference = main_itab-reference AND
            partn_func EQ 'AP' .

*" Do not user this code
*LOOP AT wfa_itab.
*
*  MODIFY main_itab TRANSPORTING wf_ind WHERE
*  reference EQ wfa_itab-reference.
*
*  APPEND main_itab.
*ENDLOOP.

*" Instead use this code
SORT wfa_itab BY reference.
LOOP AT main_itab.
  l_index = sy-tabix.

  READ TABLE wfa_itab WITH KEY reference = main_itab-reference
                      BINARY SEARCH.

  IF sy-subrc = 0.
    main_itab-wf_ind = wfa_itab-wf_ind.
    MODIFY main_itab INDEX l_index.
  ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Let me know if you still have a problem.

Regards,

RS

3 REPLIES 3
Read only

Former Member
0 Likes
540

Hi,

Before the modify statement move the values to the header line..

main_itab-wf_ind = <b>'pass some value'</b>.

Modify main_itab transporting wf_ind where

reference EQ WFA_itab-reference.

Thanks,

Naren

Read only

Former Member
0 Likes
541

Hi,

Check this code.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DATA: BEGIN OF wfa_itab OCCURS 0,
        reference LIKE zest1940_sfa_ptf-reference,
        wf_ind LIKE zest1940_sfa_ptf-name,
END OF wfa_itab.

DATA: l_index LIKE sy-tabix.   *" New variable inserted

SELECT
      reference
      name FROM zest1940_sfa_ptf
      INTO TABLE wfa_itab
      FOR ALL ENTRIES IN main_itab
      WHERE reference = main_itab-reference AND
            partn_func EQ 'AP' .

*" Do not user this code
*LOOP AT wfa_itab.
*
*  MODIFY main_itab TRANSPORTING wf_ind WHERE
*  reference EQ wfa_itab-reference.
*
*  APPEND main_itab.
*ENDLOOP.

*" Instead use this code
SORT wfa_itab BY reference.
LOOP AT main_itab.
  l_index = sy-tabix.

  READ TABLE wfa_itab WITH KEY reference = main_itab-reference
                      BINARY SEARCH.

  IF sy-subrc = 0.
    main_itab-wf_ind = wfa_itab-wf_ind.
    MODIFY main_itab INDEX l_index.
  ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Let me know if you still have a problem.

Regards,

RS

Read only

Former Member
0 Likes
540

Try this.

loop at WFA_itab.

read table main_itab with key reference = WFA_itab-reference.

if sy-subrc = 0

Modify main_itab transporting wf_ind where

reference EQ WFA_itab-reference.

endif.

endloop.

Hope it works,

Shreekant