‎2009 Apr 21 7:05 PM
Dear gurus.
This is my code please guide me where im wrong..
TABLES: vbap , vbup.
DATA: abc LIKE vbup OCCURS 1 WITH HEADER LINE.
DATA: status LIKE vbup-gbsta.
status = 'C'.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECT-OPTIONS so FOR vbup-vbeln OBLIGATORY.
SELECT-OPTIONS li FOR vbup-posnr OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 100.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK b2 FOR 4 LINES,
TAB (50) title USER-COMMAND '' DEFAULT SCREEN 100,
END OF BLOCK b2.
INITIALIZATION.
title = 'Selection OF Sales Order And Line Items'.
START-OF-SELECTION.
SELECT *
FROM vbup
INTO TABLE abc
WHERE gbsta EQ 'A'
AND lfgsa EQ 'A'
AND absta EQ 'A'.LOOP AT abc WHERE vbeln IN so AND posnr IN li.
abc-gbsta = status.
abc-lfgsa = status.
abc-absta = status.
vbup-gbsta = abc-gbsta.
vbup-lfgsa = abc-lfgsa.
vbup-absta = abc-absta.
APPEND abc.
MODIFY vbup FROM TABLE abc.
ENDLOOP.
‎2009 Apr 21 7:30 PM
This will run into infinite loop ...
LOOP AT abc WHERE vbeln IN so AND posnr IN li.
abc-gbsta = status.
abc-lfgsa = status.
abc-absta = status.
vbup-gbsta = abc-gbsta.
vbup-lfgsa = abc-lfgsa.
vbup-absta = abc-absta.
APPEND abc. <-- remove this statement
MODIFY vbup FROM TABLE abc.
ENDLOOP.
‎2009 Apr 21 7:30 PM
This will run into infinite loop ...
LOOP AT abc WHERE vbeln IN so AND posnr IN li.
abc-gbsta = status.
abc-lfgsa = status.
abc-absta = status.
vbup-gbsta = abc-gbsta.
vbup-lfgsa = abc-lfgsa.
vbup-absta = abc-absta.
APPEND abc. <-- remove this statement
MODIFY vbup FROM TABLE abc.
ENDLOOP.
‎2009 Apr 21 7:34 PM
If i remove the append code
then the standard table vbup is not modified
it contains the same previous values.
‎2009 Apr 21 7:45 PM
LOOP AT abc WHERE vbeln IN so AND posnr IN li.
abc-gbsta = status.
abc-lfgsa = status.
abc-absta = status.
vbup-gbsta = abc-gbsta.
vbup-lfgsa = abc-lfgsa.
vbup-absta = abc-absta.
APPEND abc. "Coment this
modify abc index Sy-tabix. "write this
MODIFY vbup FROM TABLE abc. "you are updating VBUP inside the loop so you can update by line by line
Modify VBUP from abc. "write this
if sy-subrc = o.
commit work.
else.
roll back.
endif.
ENDLOOP.
Regrads,
Prabhudas
‎2009 Apr 21 7:46 PM
try this way
LOOP AT abc WHERE vbeln IN so AND posnr IN li.
abc-gbsta = status.
abc-lfgsa = status.
abc-absta = status.
vbup-gbsta = abc-gbsta.
vbup-lfgsa = abc-lfgsa.
vbup-absta = abc-absta.
modify abc transporting gbsta lfgsa absta . " changing the internal table data.
MODIFY vbup FROM TABLE abc. " changing the DB table
ENDLOOP.
‎2009 Apr 21 7:59 PM
You are trying to modify a standard SAP table. Have you done the analysis to ensure that there will not be problems with data consistency?
Rob