01-13-2011 6:57 PM
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
01-13-2011 7:38 PM
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
01-13-2011 7:43 PM
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
01-13-2011 8:00 PM
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
01-13-2011 9:39 PM
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.
01-13-2011 10:09 PM
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 ?
01-13-2011 10:16 PM
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
01-13-2011 10:26 PM
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.