Skip to Content
0
Former Member
Mar 06, 2009 at 02:40 PM

Problem with data gaetting saved in table

26 Views

Hi Experts,

Please check the below code and advice me,

SELECT ZP_STOCK ZD_QTY MATNR IDNRK LIFNR FROM ZSUB INTO CORRESPONDING FIELDS 
     OF TABLE IT_ZSUB FOR ALL ENTRIES IN IT_FINAL WHERE MATNR = IT_FINAL-MATNR
                         AND IDNRK = IT_FINAL-IDNRK AND LIFNR = IT_FINAL-LIFNR.
                                                        



  LOOP AT IT_FINAL.
    READ TABLE IT_ZSUB WITH KEY MATNR = IT_FINAL-MATNR
                                IDNRK = IT_FINAL-IDNRK
                                LIFNR = IT_FINAL-LIFNR.
    MOVE IT_ZSUB-ZP_STOCK TO IT_FINAL-ZP_STOCK.
    MOVE IT_ZSUB-ZD_QTY   TO IT_FINAL-ZD_QTY.
    MODIFY IT_FINAL.
  ENDLOOP.

-


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
               RS_SELFIELD TYPE SLIS_SELFIELD.


  CASE R_UCOMM.
    WHEN '&ENT'.
      LOOP AT IT_FINAL.
        IF IT_FINAL-ZP_STOCK <> 0.
          IT_FINAL-ZD_QTY = IT_FINAL-CLOS - IT_FINAL-ZP_STOCK.
        ELSE.
          IT_FINAL-ZP_STOCK = 0.
        ENDIF.
        MODIFY IT_FINAL.
      ENDLOOP.


    WHEN '&SAVE'.
      LOOP AT IT_FINAL.
        MOVE IT_FINAL-MATNR TO ZSUB-MATNR.
        MOVE IT_FINAL-IDNRK TO ZSUB-IDNRK.
        MOVE IT_FINAL-LIFNR TO ZSUB-LIFNR.
        MOVE IT_FINAL-ZD_QTY TO ZSUB-ZD_QTY.
        MOVE IT_FINAL-ZP_STOCK TO ZSUB-ZP_STOCK.
        MODIFY ZSUB.
      ENDLOOP.

  ENDCASE.
ENDFORM.                    "USER_COMMAND

And in my out put :

-


Finished goods (matnr) - Raw material1*(idnrk) -

Finished goods (matnr) - Raw material2*(idnrk) -

Finished goods (matnr) - Raw material3*(idnrk) - it_sub-zp_stock - it_sub-zd_qty.

-


As above only for the last idnrk ie raw material 3 , it_sub-zp_stock & it_sub-zd_qty is getting saved in table .

Please advice me if there is any resolution for this problem.

Thanks

Karthik