Skip to Content

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    May 29, 2017 at 11:06 AM

    Hi Rohan,

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

    Regards,

    Krishna Chaitanya.

    Add comment
    10|10000 characters needed characters exceeded

  • May 29, 2017 at 08:19 AM

    hi

    put endloop statement before else statement like below

    ENDLOOP.

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

    Add comment
    10|10000 characters needed characters exceeded

  • May 29, 2017 at 10:16 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • May 29, 2017 at 10:39 AM

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

    Add comment
    10|10000 characters needed characters exceeded

  • May 30, 2017 at 07:23 AM

    then follow

    either

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

    or

    krishna chaithanya answer

    Add comment
    10|10000 characters needed characters exceeded