Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Append a new line while using Field Symbols

Hi,

Below is a snippet of my code

DATA: ls_data_package LIKE LINE OF DATA_PACKAGE[].

FIELD-SYMBOLS:<ls_data_package> LIKE LINE OF DATA_PACKAGE[].

zbib_sysn_temp = <ls_data_package>-/bic/zbib_sysn+off3(off4).

<ls_data_package>-/bic/zd_user = <ls_data_package>-/bic/zbib_sysn(off).

<ls_data_package>-/bic/zwrk = <ls_data_package>-/bic/zbib_sysn+off1.

I want to insert a new line to the data package, with all the fields same while adding the above two,

except for,

<ls_data_package>-/bic/zd_user = zbib_sysn_temp

<ls_data_package>-/bic/zitm = 2.

Note: by default the field /bic/zitm = 1. So while adding for the 1st time it is set to 1 by default. I want to add a second (new line) to the datapackage which has all fields same except for the /bic/zd_user and the /bic/zitm = 2.

Please help me with this code,

CD

Tags:
Former Member
Former Member replied

Don't know your exact logic...so its very difficult to code...but try this:

Do you really wanna add just a single record in the internal table DATA_PACKAGE?

DATA: off, off1, off2, off3, off4, off5, off6 TYPE i.
DATA: zbib_sysn_temp TYPE string.
DATA: ls_data_package LIKE LINE OF DATA_PACKAGE[].
FIELD-SYMBOLS:<ls_data_package> LIKE LINE OF DATA_PACKAGE[].
 
SORT DATA_PACKAGE BY /bic/zbib_id.
 " This will work only when DATA_PACKAGE ASSIGNING has a single record
Read table DATA_PACKAGE ASSIGNING <ls_data_package> index 1.
 
IF sy-subrc = 0 and <ls_data_package>-/bic/zbib_sysn IS NOT INITIAL.

TRANSLATE <ls_data_package>-/bic/zbib_sysn TO UPPER CASE.

FIND '/' IN <ls_data_package>-/bic/zbib_sysn MATCH OFFSET off2.

zbib_sysn_temp = <ls_data_package>-/bic/zbib_sysn+off3(off4).
<ls_data_package>-/bic/zd_user = <ls_data_package>-/bic/zbib_sysn(off).

 IF sy-subrc EQ 0.
<ls_data_package>-/bic/zitm = '2'.
 append <ls_data_package> to DATA_PACKAGE.
"now DATA_PACKAGE should have two records  
 endif.
endif.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question