Skip to Content
author's profile photo
Former Member

using a loop end loop

I have the following code and it doens't like my loop statement. it says it can be converted to line of t_ord_data

DATA: BEGIN OF TY_ORD_TYPE_DATA,

SALES_ORDER LIKE /BIC/AZOS_O5900-DOC_NUMBER,

SALES_ITEM LIKE /BIC/AZOS_O5900-S_ORD_ITEM,

SCHED_LINE LIKE /BIC/AZOS_O5900-SCHED_LINE,

SALE_DOC_TYPE LIKE /BIC/AZOS_O5900-DOC_TYPE,

REF_DOC LIKE /BIC/AZOS_O5900-REFER_DOC,

REF_ITEM LIKE /BIC/AZOS_O5900-REFER_ITM,

REQ_DATE LIKE /BIC/AZOS_O5900-REQ_DATE,

ZRELSDQTY LIKE /BIC/AZOS_O5900-/BIC/ZRELSDQTY,

ZSHIPQTY LIKE /BIC/AZOS_O5900-/BIC/ZSHIPQTY,

ZAVAILQTY LIKE /BIC/AZOS_O5900-/BIC/ZAVAILQTY,

ZTLTVALUE LIKE /BIC/AZOS_O5900-/BIC/ZTLTVALUE,

ZSHIPNOS LIKE /BIC/AZOS_O5900-/BIC/ZSHIPNOS,

END OF TY_ORD_TYPE_DATA.

DATA: T_ORD_DATA LIKE STANDARD TABLE OF TY_ORD_TYPE_DATA,

LS_DATA like line of T_ORD_DATA.

DATA: T_ZTAM_DATA LIKE STANDARD TABLE OF TY_ORD_TYPE_DATA,

LS_ZTAM_DATA like line of T_ZTAM_DATA .

LOOP AT T_ORD_DATA INTO T_ZTAM_DATA.

DELETE T_ORD_DATA WHERE DOC_TYPE NE 'ZLZM'.

END LOOP.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Posted on Aug 21, 2007 at 02:18 PM

    Hi,

    Change this way

    "      Comment Loop and Endloop
    *LOOP AT T_ORD_DATA INTO T_ZTAM_DATA.
    DELETE T_ORD_DATA WHERE DOC_TYPE NE 'ZLZM'.
    
    *END LOOP.   "<<< Its not END LOOP its ENDLOOP
    
    or
    
    LOOP AT T_ORD_DATA INTO LS_DATA WHERE DOC_TYPE NE 'ZLZM'.
    
    DELETE T_ORD_DATA INDEX SY-TABIX.
    
    ENDLOOP. 
    
    

    aRs

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 21, 2007 at 02:18 PM

    Hi lmmich,

    It should be

    LOOP T_ORD_DATA into LS_DATA.

    ENDLOOP.

    In the code that you have pasted, you are looping your T_ORD_DATA table in to another internal table T_ZTAM_DATA. You need to use WORK AREA for looping.

    <b>Reward points for helpful answers.</b>

    Best Regards,

    Ram.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      but I need it to fill the other internal talbe with doc type = zlzm so how do i get this to work? do i use append then to the other internal table

  • author's profile photo
    Former Member
    Posted on Aug 21, 2007 at 02:27 PM

    DATA: BEGIN OF TY_ORD_TYPE_DATA,

    SALES_ORDER LIKE /BIC/AZOS_O5900-DOC_NUMBER,

    SALES_ITEM LIKE /BIC/AZOS_O5900-S_ORD_ITEM,

    SCHED_LINE LIKE /BIC/AZOS_O5900-SCHED_LINE,

    SALE_DOC_TYPE LIKE /BIC/AZOS_O5900-DOC_TYPE,

    REF_DOC LIKE /BIC/AZOS_O5900-REFER_DOC,

    REF_ITEM LIKE /BIC/AZOS_O5900-REFER_ITM,

    REQ_DATE LIKE /BIC/AZOS_O5900-REQ_DATE,

    ZRELSDQTY LIKE /BIC/AZOS_O5900-/BIC/ZRELSDQTY,

    ZSHIPQTY LIKE /BIC/AZOS_O5900-/BIC/ZSHIPQTY,

    ZAVAILQTY LIKE /BIC/AZOS_O5900-/BIC/ZAVAILQTY,

    ZTLTVALUE LIKE /BIC/AZOS_O5900-/BIC/ZTLTVALUE,

    ZSHIPNOS LIKE /BIC/AZOS_O5900-/BIC/ZSHIPNOS,

    END OF TY_ORD_TYPE_DATA.

    DATA: T_ORD_DATA LIKE STANDARD TABLE OF TY_ORD_TYPE_DATA,

    LS_DATA like TY_ORD_TYPE_DATA.

    DATA: T_ZTAM_DATA LIKE STANDARD TABLE OF TY_ORD_TYPE_DATA,

    LS_ZTAM_DATA like TY_ORD_TYPE_DATA.

    LOOP AT T_ORD_DATA INTO LS_DATA.

    DELETE T_ORD_DATA WHERE DOC_TYPE NE 'ZLZM'.

    END LOOP.

    if you are just deleting the records from t_ord_data you dont need to loop.

    you can just say like

    DELETE T_ORD_DATA WHERE DOC_TYPE NE 'ZLZM'.

    Thanks

    Mahesh

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 21, 2007 at 02:34 PM

    Hi Immich,

    If you want to delete the records from the internal table TY_ORD_TYPE_DATA which does not have doctype zzlm, then you dont need to use the loop statement.

    You can directly write the code as,

    DELETE TY_ORD_TYPE_DATA where doctype NE zzlm.

    If you want to move the records (which doesnot have doctype zzlm) from TY_ORD_TYPE_DATA into T_ZTAM_DATA, then you need to write the code like below,

    <b>TYPES</b>: BEGIN OF TY_ORD_TYPE_DATA,

    " fields declared here

    END OF TY_ORD_TYPE_DATA.

    DATA: T_ORD_DATA <b>TYPE STANDARD TABLE OF</b> TY_ORD_TYPE_DATA,

    LS_DATA <b>TYPE TY_ORD_TYPE_DATA</b>.

    DATA: T_ZTAM_DATA <b>TYPE STANDARD TABLE OF</b> TY_ORD_TYPE_DATA,

    LS_ZTAM_DATA <b>TYPE TY_ORD_TYPE_DATA</b> .

    LOOP at TY_ORD_TYPE_DATA into LS_DATA WHERE doctyp NE zzlm.

    LS_ZTAM_DATA = LS_DATA.

    APPEND LS_ZTAM_DATA to T_ZTAM_DATA.

    ENDLOOP.

    <i><b>Reward points for helpful answers.</b></i>

    Best Regards,

    Ram.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 21, 2007 at 03:45 PM

    You don't need a loop. Just do it like this.

    T_ZTAM_DATA[] = T_ORD_DATA[].

    DELETE T_ORD_DATA WHERE DOC_TYPE NE 'ZLZM'.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      thanks all for your help. I will award points. I am still having issues with the following code though. T_ZTAM_DATA. is empty but my second select stament grabs every record from /BIC/AZOS_O5900. why would that be?

      LOOP AT T_ORD_DATA INTO ls_data

      WHERE sale_DOC_TYPE = 'ZLZM'.

      LS_ZTAM_DATA = LS_DATA.

      append ls_data to T_ZTAM_DATA.

      ENDLOOP.

      SELECT DOC_NUMBER S_ORD_ITEM SCHED_LINE DOC_TYPE REFER_DOC REFER_ITM

      REQ_DATE /BIC/ZRELSDQTY /BIC/ZSHIPQTY /BIC/ZAVAILQTY

      /BIC/ZTLTVALUE /BIC/ZSHIPNOS

      INTO TABLE T_final_DATA

      FROM /BIC/AZOS_O5900

      FOR ALL ENTRIES IN T_ZTAM_DATA

      WHERE

      refer_doc = T_ZTAM_DATA-sales_order AND

      refer_itm = T_ZTAM_DATA-SALES_ITEM AND

      req_date = T_ZTAM_DATA-REQ_DATE AND

      DOC_TYPE = 'ZTAM'.

  • author's profile photo
    Former Member
    Posted on Aug 21, 2007 at 06:12 PM

    thanks for all the help

    Add comment
    10|10000 characters needed characters exceeded