Skip to Content
avatar image
Former Member

Structure is not getting filled in the subroutine

Hi Gurus,

I'm working on a Z-report ZMB52 for fetching Reserved Stock and showing it in a column.

The following code in a subroutine I've written for the same.

DATA: GS_RESB LIKE LINE OF GT_RESB.

CLEAR: BESTAND.

IF BESTAND[] IS NOT INITIAL.

SELECT MATNR
BDMNG
FROM RESB
INTO TABLE GT_RESB
FOR ALL ENTRIES IN BESTAND[]
WHERE MATNR EQ BESTAND-MATNR.

IF SY-SUBRC EQ 0.
SORT GT_RESB BY MATNR.

LOOP AT BESTAND.

READ TABLE GT_RESB INTO GS_RESB WITH KEY MATNR = BESTAND-MATNR. "BINARY SEARCH.
IF SY-SUBRC EQ 0.
MODIFY BESTAND TRANSPORTING BDMNG WHERE MATNR = BESTAND-MATNR.
ENDIF.

CLEAR: BESTAND, GS_RESB.

ENDLOOP.
ENDIF.
ENDIF.



When I debug, I can see that the structure GS_RESB is not getting filled through the READ TABLE statement. However, GT_RESB shows the data.

Could you please tell me where am I going wrong and a way to correct it?

Thanks in Advance!


Best Regards,

Ashutosh.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Sep 18, 2014 at 06:43 AM

    Hi Joshi

    You can use

    LOOP AT GT_RESB INTO GS_RESB WHERE MATNR = BESTAND-MATNR. "BINARY SEARCH.

    MODIFY BESTAND TRANSPORTING BDMNG WHERE MATNR = BESTAND-MATNR.

    CLEAR: BESTAND, GS_RESB.

    ENDLOOP.


    And please check in debug BESTAND-MATNR .


    Best regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 18, 2014 at 06:35 AM

    Dear Joshi,

    Your read statement is correct. you are looping on itab BESTAND. check BESTAND is not initial.
    and GT_RESB contain all materials present in BESTAND.

    if you are using Binary Search then both the internal tables should be sorted.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 18, 2014 at 08:24 AM

    Hi All,

    Actually the problem was, I had forgotten to pass the value of BDMNG to BESTAND.

    Writing this statement just before MODIFY helped out.

    BESTAND-BDMNG = GS_RESB-BDMNG. 😊


    Thanks anyways!


    Best Regards,

    Ashutosh.

    Add comment
    10|10000 characters needed characters exceeded