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

Code

Former Member
0 Likes
870

Hi All,

SELECT aufnr INTO afpo-aufnr FROM afpo UP TO 1 ROWS
                   FOR ALL ENTRIES IN itab
                   WHERE aufnr EQ itab-prodorder.
      ENDSELECT.
      IF sy-subrc EQ 0.
        SELECT aufnr posnr wemng
                    INTO CORRESPONDING FIELDS OF TABLE it_afpo
                    FROM afpo
                    FOR ALL ENTRIES IN itab
                    WHERE aufnr EQ itb-prodorder.
        SORT it_afpo BY aufnr.
      ENDIF.

Can I write this in a better way?

Thanks and Regards,

Pooja

Moderator message - Please ask a specific question - post locked

Edited by: Rob Burbank on Aug 13, 2009 12:35 PM

5 REPLIES 5
Read only

Former Member
0 Likes
836

yes, you can use pretty print !!!

Read only

Former Member
0 Likes
836

using just one select, u r entry to the same tables twice, so dont u access one time only.

sure that u can writte better,

good luck 😛

Regards

Read only

Former Member
0 Likes
836

if aufnr is the first field in internal table afpo, you could use

 SELECT aufnr INTO TABLE afpo FROM afpo UP TO 1 ROWS
                   FOR ALL ENTRIES IN itab
                   WHERE aufnr EQ itab-prodorder.

This way you'll get rid of the ugly select-endselect.

Read only

Former Member
0 Likes
836

Hi ,

No need of the first select.

Just do like below.

if itab[] is not initial.
        SELECT aufnr posnr wemng
                    INTO CORRESPONDING FIELDS OF TABLE it_afpo
                    FROM afpo
                    FOR ALL ENTRIES IN itab
                    WHERE aufnr EQ itb-prodorder.
        SORT it_afpo BY aufnr.
      ENDIF.

regards,

Ankur Parab

Read only

Former Member
0 Likes
836

Just use one select statement, don't know why you are doing it twice.

      IF itab[] IS NOT INITIAL.
        SELECT aufnr posnr wemng INTO CORRESPONDING FIELDS OF TABLE it_afpo
                                                               FROM afpo
                                                 FOR ALL ENTRIES IN itab
                                                              WHERE aufnr EQ itab-prodorder.
        SORT it_afpo BY aufnr.
      ENDIF.