‎2007 Apr 05 6:12 PM
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.
‎2007 Apr 05 6:25 PM
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
‎2007 Apr 05 6:22 PM
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
‎2007 Apr 05 6:25 PM
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
‎2007 Apr 05 6:29 PM
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