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: 

display the vendor master data from LFA1 table

display the vendor master data from LFA1 table, vendors should be filterd by country code and order by city by accepting the selection screen range and consider any 10 fields to display the output.

TABLES: LFA1.

DATA IT LIKE TABLE OF LFA1.
DATA WA LIKE LINE OF IT.
SELECT * FROM LFA1 INTO TABLE IT ORDER BY ORT01.

if sy-subrc <> 0.
Sort IT by ORT01.



LOOP AT IT INTO WA.
WRITE : / WA-LIFNR,
WA-LAND1,
WA-STRAS,
WA-BRSCH,
WA-ERDAT,
WA-ERNAM,
WA-*****,
WA-SPRAS,
WA-STKZU,
WA-KRAUS.
Else.
Message 'No Records Founds' TYPE 'E'.

ENDLOOP.
endif.

What could be wrong with the code, I am even unable to execute it after removing the if, else control blocks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rohan,

Give sy-subrc = 0. instead sy-subrc <> 0.

Regards,

Krishna Chaitanya.

5 REPLIES 5

former_member241258
Active Participant
0 Kudos

hi

put endloop statement before else statement like below

ENDLOOP.

Else.
Message 'No Records Founds' TYPE 'E'.
endif.

0 Kudos

Hi Krishna,

Made changes as below, but when pressing F8 not executing, what could be the problem?

TABLES: LFA1.

DATA IT LIKE TABLE OF LFA1.
DATA WA LIKE LINE OF IT.
SELECT * FROM LFA1 INTO TABLE IT ORDER BY ORT01.

if sy-subrc <> 0.
Sort IT by ORT01.



LOOP AT IT INTO WA.
WRITE : / WA-LIFNR,
WA-LAND1,
WA-STRAS,
WA-BRSCH,
WA-ERDAT,
WA-ERNAM,
WA-*****,
WA-SPRAS,
WA-STKZU,
WA-KRAUS.
ENDLOOP.
Else.
Message 'No Records Founds' TYPE 'E'.


endif.

0 Kudos

in debugger it does not even go to the write statement.

Former Member
0 Kudos

Hi Rohan,

Give sy-subrc = 0. instead sy-subrc <> 0.

Regards,

Krishna Chaitanya.

former_member241258
Active Participant
0 Kudos

then follow

either

Give sy-subrc = 0. instead sy-subrc <> 0.

or

krishna chaithanya answer