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: 

Add ABAP code in InfoSet query - Getting error message

Babek907
Explorer
0 Kudos

When I added the ABAP code in the InfoSet query getting an error message: The data object "<G00_WA>" does not have a structure and therefore does not have a component called "MSEG-BWART".

Code Section: 1 DATA

 DATA: str TYPE string.
FIELD-SYMBOLS: <g00> TYPE table.
FIELD-SYMBOLS: <g00_wa> TYPE any.

Code Section: 7 END-OF-SELECTION (after List)

str = '%G00[]'.
ASSIGN (str) TO <g00>.
LOOP AT <g00> ASSIGNING <g00_wa>.
IF <g00_wa>-mseg-bwart = '102'.
<g00_wa>-dmbtr = <g00_wa>-dmbtr * -1.
<g00_wa>-menge = <g00_wa>-menge * -1.
ENDIF.
ENDLOOP.
MODIFY <g00> FROM <g00_wa>.
COMMIT WORK.
1 ACCEPTED SOLUTION

Babek907
Explorer
0 Kudos

Hi Sandra Rossi,

I am trying to add codes in the SQ02 InfoSet. When I am trying to execute the query getting dump.

5 REPLIES 5

Sandra_Rossi
Active Contributor
0 Kudos

The compiler doesn't accept the static form:

<g00_wa>-mseg-bwart

because you declared a generic type:

FIELD-SYMBOLS: <g00_wa> TYPE any.

Instead, you should use the dynamic form so that to bypass the compiler static checks:

ASSIGN COMPONENT 'MSEG-BWART' OF STRUCTURE <g00_wa> TO FIELD-SYMBOL(<mseg_bwart>).
IF sy-subrc = 0 AND <mseg_bwart> = '102'.
  ...
ENDIF.

0 Kudos

Hi Sandra Rossi,

Thank you for responding but I tried the mentioned code and got an error message. after execute I debugged the code:

1) sy-subrc got 4 not 0

2) once I comment sy-subrc got dump

str = '%G00[]'.
ASSIGN (str) TO <g00>.
ASSIGN COMPONENT 'MSEG-BWART' OF STRUCTURE
<g00_wa> TO FIELD-SYMBOL(<mseg_bwart>).
ASSIGN COMPONENT 'MSEG-DMBTR' OF STRUCTURE
<g00_wa> TO FIELD-SYMBOL(<mseg_dmbtr>).
ASSIGN COMPONENT 'MSEG-MENGE' OF STRUCTURE
<g00_wa> TO FIELD-SYMBOL(<mseg_menge>).
LOOP AT <g00> ASSIGNING <g00_wa>.
IF sy-subrc EQ 0 AND <mseg_bwart> = '102'.
<mseg_dmbtr> = <mseg_dmbtr> * -1.
<mseg_menge> = <mseg_menge> * -1.
ENDIF.
ENDLOOP.

0 Kudos

It works for me:

DATA: BEGIN OF xx,
        BEGIN OF mseg,
          bwart TYPE string,
        END OF mseg,
      END OF xx.
xx-mseg-bwart = '102'.
ASSIGN COMPONENT 'MSEG-BWART' OF STRUCTURE xx TO FIELD-SYMBOL(<mseg_bwart>).
IF sy-subrc = 0 AND <mseg_bwart> = '102'.
  MESSAGE `It's alive!` TYPE 'I'.
ENDIF.

NB: Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!

Sandra_Rossi
Active Contributor
0 Kudos

Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!

Babek907
Explorer
0 Kudos

Hi Sandra Rossi,

I am trying to add codes in the SQ02 InfoSet. When I am trying to execute the query getting dump.