Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

REPORT-URGENT

Former Member
0 Kudos
158

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos
125

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**

8 REPLIES 8

Former Member
0 Kudos
126

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**

Former Member
0 Kudos
125

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

varma_narayana
Active Contributor
0 Kudos
125

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>

0 Kudos
125

HI NARAYANA,

THX FOR UR REPLY BUT IAM GETTING THE ERROR AS

INCORRECT NESTING BEFORE THE END OF PROGRAM , THE STRUCTURE INTRODUCED BY SELECT MUST BE END WITH ENDSELECT.

THIS ERROR IAM GETTING.KINDLY SEND ME THE REPLY.

THX & REWARDS,

SUNDER

0 Kudos
125

Hi..

This is the modified code to avoid that error: Changes in BOLD.

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) LIKE EKET-WEMNG, "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.

SELECT EBELN INTO TABLE ITAB FROM EKET WHERE EINDT IN MEINDT.

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

<b>OF table ITAB1</b>

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>

0 Kudos
125

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.

Former Member
0 Kudos
125

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.

Former Member
0 Kudos
125

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