Skip to Content
avatar image
Former Member

Read Statement Issue

HI,

I am facing problem with read statement, please find below my code and provide the solution.

My Internal Tables.

TYPES: BEGIN OF TYP_BSAK,

BUKRS TYPE BSAK-BUKRS,

LIFNR TYPE BSAK-LIFNR,

AUGDT TYPE BSAK-AUGDT,

GJAHR TYPE BSAK-GJAHR,

BELNR TYPE BSAK-BELNR,

BUZEI TYPE BSAK-BUZEI,

BUDAT TYPE BSAK-BUDAT,

BLART TYPE BSAK-BLART,

DMBTR TYPE BSAK-DMBTR,

SGTXT TYPE BSAK-SGTXT,

AUGBL TYPE BSAK-AUGBL,

HKONT TYPE BSAK-HKONT,

END OF TYP_BSAK.

DATA : IT_BSAK TYPE STANDARD TABLE OF TYP_BSAK WITH HEADER LINE,

WA_BSAK TYPE TYP_BSAK.

READ STATEMENT :

LOOP AT IT_BSIS INTO WA_BSIS. -> I am getting data in wa_BSIs

READ TABLE IT_BSAK INTO WA_BSAK -> I am Getting record in IT_BSAK bu the same is not populated in WA_BSAK

WITH KEY BUKRS = S_BUKRS.

IF SY-SUBRC = 0.

WA_OUTPUT-SAPSYS = 'PROBE'.

WA_OUTPUT-BUKRS = WA_BSAK-BUKRS.

WA_OUTPUT-BUKRS = WA_BSAK-BUKRS.

WA_OUTPUT-BELNR = WA_BSAK-BELNR.

WA_OUTPUT-SGTXT = WA_BSAK-SGTXT.

WA_OUTPUT-BUDAT = WA_BSAK-BUDAT.

WA_OUTPUT-AUGBL = WA_BSAK-AUGBL.

WA_OUTPUT-LIFNR = WA_LFA1-LIFNR.

WA_OUTPUT-NAME1 = WA_LFA1-NAME1.

WA_OUTPUT-STRAS = WA_LFA1-STRAS.

WA_OUTPUT-ORT01 = WA_LFA1-ORT01.

WA_OUTPUT-REGIO = WA_LFA1-REGIO.

WA_OUTPUT-PSTLZ = WA_LFA1-PSTLZ.

WA_OUTPUT-STCD2 = WA_LFA1-STCD2.

ENDIF.

APPEND WA_OUTPUT TO IT_OUTPUT.

ENDLOOP.

Thanks and Regards

VB

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 24, 2010 at 03:29 PM

    This is still a pretty basic question. Please press F1 on READ before posting here.

    Rob

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 24, 2010 at 03:30 PM

    i hope that S_BUKRS is a select option.. which is of type SIGN|OPTION|LOW|HIGH..

    so you statement

    with key BUKRS = S_BUKRS is comparing like this '1000' = 'IEQ1000'. and these defnitely are not the same... right!!!

    so what you need to do is pass a specfic BUKRS like S_BUKRS-LOW.

    where BUKRS = S_BUKRS-LOW.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      READ TABLE IT_BSAK INTO WA_BSAK -> I am Getting record in IT_BSAK bu the same is not populated in WA_BSAK

      WITH KEY BUKRS = S_BUKRS-low.

      And please be sure whether you will have more values in select options.

      Else you will need to pass s_bukrs-HIGH as well,

      Please de bug and read the H1 help.

      Thanks!

  • avatar image
    Former Member
    Jun 25, 2010 at 06:59 AM

    Hi,

    I hope You have use below code solved your problem.

    LOOP AT IT_BSIS INTO WA_BSIS

    READ TABLE IT_BSAK INTO WA_BSAK

    WITH KEY BUKRS = WA_BSIS-BUKRS.

    IF SY-SUBRC = 0.

    WA_OUTPUT-SAPSYS = 'PROBE'.

    WA_OUTPUT-BUKRS = WA_BSAK-BUKRS.

    WA_OUTPUT-BUKRS = WA_BSAK-BUKRS.

    WA_OUTPUT-BELNR = WA_BSAK-BELNR.

    WA_OUTPUT-SGTXT = WA_BSAK-SGTXT.

    WA_OUTPUT-BUDAT = WA_BSAK-BUDAT.

    WA_OUTPUT-AUGBL = WA_BSAK-AUGBL.

    WA_OUTPUT-LIFNR = WA_LFA1-LIFNR.

    WA_OUTPUT-NAME1 = WA_LFA1-NAME1.

    WA_OUTPUT-STRAS = WA_LFA1-STRAS.

    WA_OUTPUT-ORT01 = WA_LFA1-ORT01.

    WA_OUTPUT-REGIO = WA_LFA1-REGIO.

    WA_OUTPUT-PSTLZ = WA_LFA1-PSTLZ.

    WA_OUTPUT-STCD2 = WA_LFA1-STCD2.

    ENDIF.

    APPEND WA_OUTPUT TO IT_OUTPUT.

    ENDLOOP.

    Thanks

    Regards

    I.Muthukumar.

    Edited by: I.Muthukumar on Jun 25, 2010 12:43 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 25, 2010 at 10:39 AM

    Hi,

    I think you wanted to refer the bukrs value present in wa_bsis instead of s_bukrs, if it is the case refer the following logic.

    LOOP AT IT_BSIS INTO WA_BSIS. -> I am getting data in wa_BSIs

    READ TABLE IT_BSAK INTO WA_BSAK -> I am Getting record in IT_BSAK bu the same is not populated in WA_BSAK

    WITH KEY BUKRS = wa_BSIs-bukrs.

    IF SY-SUBRC = 0.

    WA_OUTPUT-SAPSYS = 'PROBE'.

    WA_OUTPUT-BUKRS = WA_BSAK-BUKRS.

    WA_OUTPUT-BUKRS = WA_BSAK-BUKRS.

    WA_OUTPUT-BELNR = WA_BSAK-BELNR.

    WA_OUTPUT-SGTXT = WA_BSAK-SGTXT.

    WA_OUTPUT-BUDAT = WA_BSAK-BUDAT.

    WA_OUTPUT-AUGBL = WA_BSAK-AUGBL.

    WA_OUTPUT-LIFNR = WA_LFA1-LIFNR.

    WA_OUTPUT-NAME1 = WA_LFA1-NAME1.

    WA_OUTPUT-STRAS = WA_LFA1-STRAS.

    WA_OUTPUT-ORT01 = WA_LFA1-ORT01.

    WA_OUTPUT-REGIO = WA_LFA1-REGIO.

    WA_OUTPUT-PSTLZ = WA_LFA1-PSTLZ.

    WA_OUTPUT-STCD2 = WA_LFA1-STCD2.

    ENDIF.

    APPEND WA_OUTPUT TO IT_OUTPUT.

    ENDLOOP.

    Regards,

    Preetham

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 25, 2010 at 11:14 AM

    Hi,

    You can follow the following steps always,

    sort it_bsak. /* this should be on required fields to be easy for searching

    loop at it_bsis into wa_bsis.

    clear wa_bsak

    read table it_bsak into wa_bsak with key bukrs = wa_bsis-bukrs binary search.

    if sy-subrc eq 0.

    /* write your append statements when seach is successful.

    endif.

    clear wa_bsis.

    endloop.

    I am not sure why are you using s_bukrs. If you clarify the requirement more, I will be able to guide you better.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 25, 2010 at 01:39 PM

    I think it's about time everyone pressed F1 on READ. 😉

    Rob

    Add comment
    10|10000 characters needed characters exceeded

    • > read (v.) to translate written text into meaningful ideas within one's own mind. People usually read to gain knowledge or to awaken their imagination. Sadly, the act of reading seems to have been "bred out" of the human race. People these days would much rather desensetize themselves with stupid rap noise and violent, pornographic, and otherwise unintelligent forms of media. If you are an ABAP developer and find it hard to read, do yourself a favor and get help. No offense! Reading is a great and powerful thing, and only by fully taking advantage of it can one open his or her mind to the possibilities of his or her own future.

      "urban dictionary" with one adjustment 😉