Application Development and Automation 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: 
Read only

Static ASSIGN with Offset Specification

Former Member
0 Likes
1,029

Hi,

While trying to work with field symbols using static ASSIGN and Offset/Length Specification, got the error as mentioned below.

So unless I mention the explicit length of the Offset or '*', I get the error. I was reading through the following link for some information & working through the code snippets when I ran into the issue,

https://help.sap.com/saphelp_nw04/helpdata/en/fc/eb38d5358411d1829f0000e829fbfe/content.htm

Any information on the same would be very helpful.

Thanks

Srujana

2 REPLIES 2
Read only

former_member201275
Active Contributor
0 Likes
882

You have to have it as follows:

FIELD-SYMBOLS <fs> TYPE ANY.
DATA: BEGIN OF line,
  string1(10) VALUE '0123456789',
  string2(10) VALUE 'abcdefghij',
  END OF line.

WRITE / line-string1+5.
ASSIGN line-string1+5(5) TO <fs>.
WRITE / <fs>.
ASSIGN line-string1+5(*) TO <fs>.
WRITE / <fs>.

Read only

0 Likes
882

Thanks for the response.

I do not get any error when I mention specific length or '*' with the offset. The only problem is when you do not mention any length with the offset.

As per link below,

https://help.sap.com/saphelp_nw04/helpdata/en/fc/eb38d5358411d1829f0000e829fbfe/content.htm

Having WRITE after ASSIGN line-string1+5 TO <fs> should result in output, 56789abcde.

Explained as,

"In this example, you can see the difference between an offset specification in a WRITE statement and an offset specification in an ASSIGN statement. With WRITE, the output is truncated at the end of LINE-STRING1. Specifying an offset greater than 9 would lead to an error during the syntax check. In the first ASSIGN statement, the memory area of length 10 beginning with offset 5 in LINE-STRING1 is assigned to the field symbol <FS>. The output is meaningful because the memory area behind LINE-STRING1 belongs to LINE-STRING2. In the second ASSIGN statement, the length specification * prevents the system from addressing the memory area after LINE-STRING1."

Same mentioned under,

http://help.sap.com/saphelp_nw70/helpdata

So just trying to figure out if I am missing on something.