‎2005 Nov 06 4:06 AM
Hi All,
There is one requirement where I've to take a string with variable length. But this program is using 'Find String Offset off length len of var_string' syntax to find out a substring within this string.
What is happening right now is when I use this syntax , program is giving short dump which I'm attaching here - \
The reason for the exception is:
The running program, "SAPLXFOR", tried to access the field "LONG_TEXT_STR", which has a
length of 65535, using "SECTION OFFSET 409 LENGTH 65535". The SECTION addition is only correct if the substring specified in the offset/length lies entirely within the field "LONG_TEXT_STR".
Could anybody suggest me how I can prevent this dump.
What I believe that I've to increase the length of the variable of the string just before 'Find ' statement.
Thanks
Regards,
Alok
‎2005 Nov 06 4:21 AM
Alok
Could you paste your code. If you declare a string, SAP will handle the length and you dont have to mention the length. Try declaring the variable as string and see if the program still dumps.
Thanks
Sunil Achyut
‎2005 Nov 06 4:51 AM
Hi Sunil,
Please find the extract of the code. I've already yried by taking the data type as string but when we call find with offset and length , the sum of offset and length becomes bigger than string length and because of this it's giving dump.
Pls suggest me if there is any other way -
*Data Declaration
data : ak_len3 type i,
ak_len2 type i,
ak_len4 type i,
ak_len1 type i,
ak_len type i,
c_len1 type i,
text_str(500).
data : textstr(80),
long_text_str(65535),
long_text_str type string,
long_text_str1(65535),
long_text_str type string,
long_txt_str(80),
i_len type i,
c_len type i,
c_i type i,
c_i1 type i,
i_pos type i,
c_pos type i,
CNT_820_SEG TYPE P, "sum 820 records tx set (ST-SE)
cnt_count type i,
cnt_count1(6),
cnt_text(10),
c_txt,
c_text1,
i_lifnr like t_regup-lifnr, " Vendor No
i_ebeln like t_regup-ebeln, " PO No (for LIV Invoices only)
i_xblnr like t_regup-xblnr, " Reference #(Vendor's Invoice no)
i_budat like t_regup-budat, " Document Date
i_sgtxt like bseg-sgtxt, " Vendor Line Item Text
i_belnr like t_regup-belnr, " SAP Document No
*002 ++ BEGIN
i_pos1 type i,
i_pos2 type i.
*002 ++ END
clear long_text_str.
ak_len1 = strlen( long_text_str ).
*Move all the data from internal table T_DTAMUSADD into a string
loop at T_DTAMUSADD .
if sy-tabix = 1.
move T_DTAMUSADD-add3 to long_text_str.
else.
move T_DTAMUSADD-add3 to long_txt_str.
concatenate long_text_str long_txt_str into long_text_str.
endif.
endloop.
*Search for '\SE' to get the position
search long_text_str for '\SE'.
*002 ++ BEGIN
i_pos = sy-fdpos.
i_pos = i_pos + 4.
move long_text_str+i_pos(2) to cnt_count1.
if cnt_count1 cs '*'.
replace '*' in cnt_count1 with ' '.
condense cnt_count1.
endif.
move cnt_count1 to cnt_count.
search long_text_str for '\ENT*1\'.
i_pos = sy-fdpos.
i_lifnr = t_regup-lifnr.
Insert new Segment 'REFVR' here.
concatenate long_text_str(i_pos) '\' 'REFVR' i_lifnr
long_text_str+i_pos into long_text_str.
cnt_count = cnt_count + 1.
*Added for multiple invoices
*Search for '\RMR to get the multiple invoices
c_len = strlen( long_text_str ).
clear i_pos.
search long_text_str for '\RMR'.
i_pos = sy-fdpos.
i_pos = i_pos + 1.
find '\RMR' in section offset i_pos length c_len of long_text_str match offset i_pos.
Thanks
Alok
‎2005 Nov 06 5:20 PM
Hi Alok,
With all the offset operations, you have to make sure that the offset you are using is valid. So you have always check your offset length against the total length of the field before you do the offset.
Regards,
Srinivas
‎2005 Nov 06 11:30 PM
Hello Alok,
maybe splitting the long string into a table with smaller chunks removes the need to search with offset at all. This might also help to make the code more readable.
Regards
Klaus
‎2005 Nov 07 12:33 AM
Also remember, strlen function will return you zero if the string has no content.
‎2005 Nov 07 12:34 AM
You are not looking for sy-subrc value after your SEARCH statements. It is very important because you are using SY-FDPOS after that which may be zero and cause the dump. Debug it and you will know.
‎2005 Nov 07 2:15 AM
Srinivas,
I am working in MRKO transaction, which is to create accounting document using vendor and material documet.
Problem is EXCHANGE RATE. I have to create accounting document as per Vendor suggested exchange rate, Not per system caliculated exchange rate.
So what i thought was, We have some exits in MRKO transaction. For each vendor we will ask user to get Vendor exchange rate and proceed with that rate. But system is taking exchange rate maintenained in system.
Challange is: I have to create accounting document as per Vendor suggested exchange rate, Not per system caliculated exchange rate.
Any body help me on this.
Thanks,
Rays
‎2005 Nov 08 3:11 PM
Hi All,
I resolved this issue. In the below FIND statement I've replaced c_len with -1.
old code
find '\RMR' in section offset i_pos length c_len of long_text_str match offset i_pos.
New code
find '\RMR' in section offset i_pos length -1 of long_text_str match offset i_pos.
Now it will search for that string '\RMR' starting from i_pos and it'll find till the end of the staring.
Thanks a lot for all your suggestions.
Regards,
Alok
‎2005 Nov 08 4:04 PM
Can you please close the post if it is resolved?
Thanks,
Srinivas