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: 

Modify Fieldsymbol Table from Work Area

Former Member
0 Kudos

Hi,

I have seen the following append statement work perfectly, at runtime <gfs_tabtable> is assigned to be a type of SFLIGHT -


FIELD-SYMBOLS: <gfs_tabtable>        TYPE STANDARD TABLE.
APPEND wa_sflight TO <gfs_tabtable>

I am trying to achieve the following but it does not seem to work (sy-subrc = 4), could you tell me where am I going wrong -


FIELD-SYMBOLS: <gfs_tabtable>        TYPE STANDARD TABLE.
MODIFY <gfs_tabtable> FROM  wa_sflight

7 REPLIES 7

Clemenss
Active Contributor
0 Kudos

Hi Grame.

something is missing.

FIELD-SYMBOLS: <gfs_tabtable>        TYPE STANDARD TABLE.
* ASSIGN GT_SFLIGHT TO <gfs_tabtable>.
APPEND wa_sflight TO <gfs_tabtable>

You can use field-symbols only if they are assigned to an existing data object. A field-symbol represents the data that it is assigned to. You can check the condition IS ASSIGNED to mal sure you can use the field-symbol.

You can

MODIFY <gfs_tabtable> FROM  wa_sflight

if there was an

ASSIGN gt_sflight to <gfs_tabtable> .

and if gt_sflight is a table of SFLIGHT rows.

Check [field-symbol documentation|http://help.sap.com/abapdocu_702/en/index.htm]

Regards,

Clemens

Former Member
0 Kudos

Hi,

The system searches the internal table for the line whose table key corresponds to the key fields in wa, if no line is found, the sy-subrc is 4.

http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb35eb358411d1829f0000e829fbfe/content.htm

regards,

Paulo Carvalho

Former Member
0 Kudos

Hi Grame,

Since the statement

MODIFY <gfs_tabtable> FROM  wa_sflight

is valid, I suspect that the following is the issue according to the SAP Help for Modify:

return code of 0 -> At least one line was changed.

retrun code 0f 4 -> No lines were changed, since no suitable line was found for the insertion using the table key, or the

specified index was greater than the current number of lines for the insertion using the table index.

Kind regards,

Robert

rajesh_paruchuru
Active Participant
0 Kudos

Hello Grame

Assuming that everything else is fine(assigning and populating data to the field-symbol(table) and the work area), I would also

expect to see the keyword TABLE after MODIFY.

MODIFY TABLE <gfs_tabtable> FROM  wa_sflight.

-Rajesh.

0 Kudos

Hi Rajesh,

The field symbol table is populated correctly and the assignments are also correct as far as I see from the debug screen. I have used the

MODIFY TABLE <gfs_tabtable> FROM wa_sflight

but it still returns a sy-subrc 4.

Should I declare a field symbol work area

<gfs_tabtableline>    TYPE ANY

and try to use the modify statement ?

Subhankar
Active Contributor
0 Kudos

Hi Grame,

Your syntax is fine, but you may miss one stuff. As per my understanding you want to update the dynamic internal table <gfs_tabtable> with work area.

If you want update an internal table with in the loop then you no need to specify index or where clause. But seems you try to update outside loop. Then you need to add index or where clause.

For details just F1 help of Modify statement.

Thanks

Subhankar

Former Member
0 Kudos

I just did the same.

You are right, looks like the row number is mandatory to modify a dynamic internal table.

LOOP AT <gfs_tabtable> ASSIGNING <gfs_tabtableline>.
        ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <gfs_tabtableline> TO <lcl_id>.
        IF <lcl_id> = wa_sflight-field1.
          MODIFY <gfs_tabtable> FROM wa_sflight INDEX sy-tabix.
        ENDIF.
      ENDLOOP.

The above code worked.