Skip to Content
author's profile photo Former Member
Former Member

REPORT-URGENT

HI gurus,

can any one correct this code . I am not getting actual output of quantity.For this iam giving the input as date.Depens upon the date iam taking po number .depend on that iam taking matr no,desc,total qty,del qty . based on total qty and del qty i want to calculate remianing qty. I am getting some garbage values and qty also not getting.so any one can correct this and reply back to me .

DATA : BEGIN OF ITAB OCCURS 2,

EBELN LIKE EKET-EBELN,

END OF ITAB .

DATA : BEGIN OF ITAB1 OCCURS 2,

MATNR LIKE EKPO-MATNR,

TXZ01 LIKE EKPO-TXZ01,

MENGE LIKE EKET-MENGE,

WEMNG LIKE EKET-WEMNG,

MOBMNG(3) TYPE C,

END OF ITAB1.

SELECT-OPTIONS MEINDT FOR EKET-EINDT.

SELECT EBELN INTO ITAB FROM EKET WHERE EINDT IN MEINDT.

APPEND ITAB.

ENDSELECT.

LOOP AT ITAB.

SELECT MATNR TXZ01 INTO CORRESPONDING FIELDS OF ITAB1 FROM EKPO WHERE EBELN = ITAB-EBELN.

APPEND ITAB1.

ENDSELECT.

ENDLOOP.

LOOP AT ITAB.

CLEAR ITAB1-MENGE .

CLEAR ITAB1-WEMNG .

SELECT MENGE WEMNG INTO CORRESPONDING FIELDS OF ITAB1 FROM EKET WHERE EBELN = ITAB-EBELN.

APPEND ITAB1.

ENDSELECT.

ENDLOOP.

LOOP AT ITAB.

clear itab1-mobmng.

ITAB1-MOBMNG = ITAB1-MENGE - ITAB1-WEMNG.

APPEND ITAB1.

ENDLOOP.

LOOP AT ITAB1.

WRITE : / ITAB1-MATNR , ITAB1-TXZ01 , ITAB1-MENGE , ITAB1-WEMNG , ITAB1-MOBMNG.

ENDLOOP.

thanks & regards,

sunder

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 28, 2007 at 04:10 AM

    Hi Sunder,

    You have taken incorrect data type for the difference field MOBMNG..

    Please declare like :

    DATA : BEGIN OF ITAB1 OCCURS 2,

    MATNR LIKE EKPO-MATNR,

    TXZ01 LIKE EKPO-TXZ01,

    MENGE LIKE EKET-MENGE,

    WEMNG LIKE EKET-WEMNG,

    MOBMNG LIKE EKET-MENGE,

    END OF ITAB1.

    Also, In the loop where you are calculating the value of MOBMNG, do not use APPEND, use MODIFY..

    Another thing, why u r using SELECT ENDSELECT... that too in a loop??? Use FOR ALL ENTRIES.. and INTO TABLE..

    Thanks and Best Regards,

    Vikas Bittera.

    **Points for useful answers**

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 28, 2007 at 04:11 AM

    Hi Sunder,

    check the code.

    &----


    *& Report ZTEST_1001 *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ztest_1001 .

    TABLES : eket.

    TYPES : BEGIN OF ty_itab,

    ebeln LIKE eket-ebeln,

    matnr LIKE ekpo-matnr,

    txz01 LIKE ekpo-txz01,

    menge LIKE eket-menge,

    wemng LIKE eket-wemng,

    END OF ty_itab .

    DATA : itab TYPE STANDARD TABLE OF ty_itab,

    wa_itab TYPE ty_itab.

    SELECT-OPTIONS meindt FOR eket-eindt.

    SELECT aebeln bmatnr btxz01 amenge a~wemng

    INTO TABLE itab

    FROM eket AS a INNER JOIN ekpo AS b ON aebeln EQ bebeln

    WHERE a~eindt IN meindt.

    LOOP AT itab INTO wa_itab.

    wa_itab-mobmng = wa_itab-menge - wa_itab-wemng.

    MODIFY itab FROM wa_itab TRANSPORTING mobmng WHERE matnr EQ wa_itab-matnr.

    CLEAR: wa_itab.

    ENDLOOP.

    LOOP AT itab INTO wa_itab.

    WRITE : / wa_itab-matnr , wa_itab-txz01 , wa_itab-menge , wa_itab-wemng , wa_itab-mobmng.

    CLEAR wa_itab.

    ENDLOOP.

    Award points if this helps.

    Regards,

    Ravi G

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 28, 2007 at 04:12 AM

    Hi Sunder...

    There are some corrections in your code.

    Find the Modified code below and Execute it and check the result.

    Observe the comments i mentioned.

    DATA : BEGIN OF ITAB OCCURS 2,

    EBELN LIKE EKET-EBELN,

    END OF ITAB .

    DATA : BEGIN OF ITAB1 OCCURS 2,

    MATNR LIKE EKPO-MATNR,

    TXZ01 LIKE EKPO-TXZ01,

    MENGE LIKE EKET-MENGE,

    WEMNG LIKE EKET-WEMNG,

    <b>MOBMNG(3) LIKE EKET-WEMNG,</b> "assign proper data type

    END OF ITAB1.

    SELECT-OPTIONS MEINDT FOR EKET-EINDT.

    start-of-selection.

    ***dont use SELECT .. ENDSELECT..it will be worst in performance.

    <b>SELECT EBELN INTO TABLE ITAB FROM EKET WHERE EINDT IN MEINDT.</b>

    if itab[] is not initial.

    **Use FOR ALL ENTRIES instead of LOOP ... ENDLOOP..

    SELECT MATNR TXZ01 INTO CORRESPONDING FIELDS OF

    table ITAB1

    FROM EKPO

    FOR ALL ENTRIES IN ITAB

    WHERE EBELN = ITAB-EBELN.

    SELECT MENGE WEMNG INTO CORRESPONDING FIELDS

    OF ITAB1

    FROM EKET

    FOR ALL ENTRIES IN ITAB

    WHERE EBELN = ITAB-EBELN.

    endif.

    LOOP AT ITAB1.

    ITAB1-MOBMNG = ITAB1-MENGE - ITAB1-WEMNG.

    MODIFY ITAB1. "Update the Record

    WRITE : / ITAB1-MATNR , ITAB1-TXZ01 , ITAB1-MENGE , ITAB1-WEMNG , ITAB1-MOBMNG.

    ENDLOOP.

    <b>Reward if Helpful.</b>

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Sunder,

      Check all select statements in your program..

      If you have used SELECT UPTO 1 ROWS or any SELECT with SINGLE or INTO TABLE addition, the write ENDSELECT in the end of that select.

      SELECT xxxx

      INTO xxx

      FROM xxx

      WHERE xxxx .

      ENDSELECT.

      Thanks and Best Regards,

      Vikas Bittera.

  • author's profile photo Former Member
    Former Member
    Posted on Aug 28, 2007 at 04:28 AM

    hi,

    try by making changes to ur code as

    LOOP AT ITAB.

    CLEAR ITAB1-MENGE .

    CLEAR ITAB1-WEMNG .

    SELECT MENGE WEMNG FROM EKET INTO CORRESPONDING FIELDS OF table ITAB1 FOR ALL ENTRIES IN ITAB WHERE EBELN = ITAB-EBELN.

    APPEND ITAB1.

    ENDLOOP.

    LOOP AT ITAB.

    clear itab1-mobmng.

    ITAB1-MOBMNG = ITAB1-MENGE - ITAB1-WEMNG.

    MODIFY ITAB1.

    if helpful reward some points.

    with regards,

    Suresh Aluri.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 28, 2007 at 04:54 AM

    Hi,

    Instead of declaring type MOBMNG(3) TYPE C , Declare MOBMNG like eket-wemng.

    Dont use append unnecessary , use modify statement.

    Hope this will helps you.

    With Regards,

    K K V

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.