2023 May 16 3:05 AM
hi i have a structure with 70 fields and in each field i need to replace some characters to space i tried this code
sample
in structure if check i check in debug
each field has length of 19
field1 = this is field1 test
field2 = test this is field2
field3 = test this is field3
etc....
code
do 70 times.<br> replace all occurences of 'test' in lv_header with space.<br>enddo.
the problem is if i put the lv_header only
the field value become
field1 = this is field1 this
field2 = is field2 this is f
field3 = ield3
i can't put something like this -> lv_header-field1 / lv_header-field2 etc,... in replace all occurences because there are 70 fields needed to replace
how i can replace the fields value inside a loop? is my code correct or there is an additional code for this?
2023 May 16 4:30 AM
You can try it with something like this
DO 70 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE my_workarea TO <my_field_symbol>. "my_field_symbol Type any
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
REPLACE ALL OCCURENCES OF 'test' IN <my_field_symbol> WITH space.
ENDDO.
2023 May 16 4:30 AM
You can try it with something like this
DO 70 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE my_workarea TO <my_field_symbol>. "my_field_symbol Type any
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
REPLACE ALL OCCURENCES OF 'test' IN <my_field_symbol> WITH space.
ENDDO.
2023 May 16 7:08 AM
2023 May 16 7:29 AM
Tomorrow I was a litle bit tired, you are right: EXIT is better than CONTINUE
2023 May 16 7:04 AM
The term "workarea" is a term used in the ABAP documentation to name few placeholders in some ABAP statements where "workarea" can represent anything, not only structures. For instance, READ TABLE itab INTO workarea, workarea can be anything (structure, scalar/elementary, internal table, etc.)
You can say "structure" or "structured variable" instead.
2023 May 16 7:06 AM