Application Development and Automation 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: 
Read only

Please, pretty please, correct this code

Former Member
0 Likes
707
LOOP AT FINAL.
    IF FINAL-PSTYV EQ 'ZTAO'.
      DATA : MPSPHI LIKE PRPS-PSPHI.
      DATA : MPRPS LIKE PRPS OCCURS 0 WITH HEADER LINE.
      DATA : MOBJRN LIKE RPSCO-OBJNR.
            
      SELECT SINGLE * FROM PRPS WHERE PSPNR = FINAL-PS_PSP_PNR.

      MPSPHI = PRPS-PSPHI.

      SELECT * FROM PRPS INTO TABLE MPRPS WHERE PSPHI = MPSPHI.

      SORT MPRPS BY OBJNR.

      LOOP AT MPRPS.

        MOBJNR = PRPS-OBJNR.

      ENDLOOP. 

endloop.

when I debug the code MOBJNR is not changing it is taking from row value even it is running in the loop.

kindly correct this code

regards,

Edited by: Matt on Dec 3, 2008 3:53 PM - Subject made less demanding

5 REPLIES 5
Read only

Former Member
0 Likes
685

Hi Raj,


DATA : MPSPHI LIKE PRPS-PSPHI.
DATA : MPRPS LIKE PRPS OCCURS 0 WITH HEADER LINE.
DATA : MOBJRN LIKE RPSCO-OBJNR.

LOOP AT FINAL.
IF FINAL-PSTYV EQ 'ZTAO'.
SELECT SINGLE * FROM PRPS WHERE PSPNR = FINAL-PS_PSP_PNR.
MPSPHI = PRPS-PSPHI.

SELECT * FROM PRPS INTO TABLE MPRPS WHERE PSPHI = MPSPHI.
SORT MPRPS BY OBJNR.

LOOP AT MPRPS.
MOBJNR = PRPS-OBJNR.
ENDLOOP. 

ENDLOOP.

In the loop for MPRPS, the object number wil be overwritten and everytime only the last record from the table MPRPS will be available.

Change that part. It should work. If you want to store the object number in another table, you need to declare a table of type MOBJNR and you need to append records to that table.

Note: Please avoid selects inside loop as it would affect the performance.

Best Regards,

Ram.

Read only

Former Member
0 Likes
685

u have looped MPRPS but moving PRPS.

move MPRPS then it will work

Regards,

Ajay

Read only

paolo_romano2
Participant
0 Likes
685

hi raj,

LOOP AT FINAL.

IF FINAL-PSTYV EQ 'ZTAO'.

DATA : MPSPHI LIKE PRPS-PSPHI.

DATA : MPRPS LIKE PRPS OCCURS 0 WITH HEADER LINE.

DATA : MOBJRN LIKE RPSCO-OBJNR.

SELECT SINGLE * FROM PRPS WHERE PSPNR = FINAL-PS_PSP_PNR.

MPSPHI = PRPS-PSPHI.

SELECT * FROM PRPS INTO TABLE MPRPS WHERE PSPHI = MPSPHI.

SORT MPRPS BY OBJNR.

LOOP AT MPRPS.

MOBJNR = MPRPS-OBJNR.

ENDLOOP.

endloop.

cheers,

P

Read only

0 Likes
685

Hi Paolo,

thanks I got it. Some times it happens...

regards,

Read only

0 Likes
685

hi raj,

you're right...I make such an error thousands of times...and every time I go crazy to recognize it...

cheers,

Paolo