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

Problem processing results from SO_OBJECT_READ

Former Member
0 Likes
2,730

I am calling function SO_OBJECT_READ and it is returning to me a table called OBJCONT which has one field which is a 255 char field. This is the message content of the SBWP email. It seems to split each line using two # like this:

This is my first line of text.##This is my second line of text.##This is my third line of text.

I am trying to process this string by finding the # symbol in the field. I have tried the following but nothing works:

FIND '#' IN OBJCONT-LINE.

IF OBJCONT-LINE CS '#'.

VAR-POS = SY-FDPOS.

ENDIF.

SPLIT OBJCONT-LINE AT '#' INTO TABLE OBJECT_CONTENTS.

None of the above examples seem to process the '#' characters. It is almost like it is a placeholder for a Carriage return or Line Feed? Has anyone come across this problem before? If I declare another field within my program I can process '#' fine using exact same examples described above.

EG.

DATA: VAR-TEST(10) TYPE C.

VAR-TEST = '123###456'.

FIND '#' IN VAR-TEST MATCH OFFSET VAR-POS.

So why does it not work for the table that I have returned from SO_OBJECT_READ?

14 REPLIES 14
Read only

former_member156446
Active Contributor
0 Likes
2,273

when ever the person hits an enter in the text field there the # is triggered in the field.. which is called a line field as u suspected.

I had a scenario where I had a # at the end so I found the string length and removed the last character..

If I remember there is some alternative like decelaring the # like

data: c_feed type X value '/OD'.

this doesn't work for a unicode system though.

Read only

0 Likes
2,273

The problem is that the ## is repeated throughout the string just not at the end. I can not change the results that the standard SAP function gives me so I need to somehow process the two ##'s?

Read only

0 Likes
2,273

Hi Brad, Just remove ## using the following code. It just replaces with space. Try it . It works i believe.


DATA objcont LIKE soli  OCCURS 0 WITH HEADER LINE.

objcont-line = 'This ##is my 1 line##'.
APPEND objcont.
CLEAR  objcont.
objcont-line = 'This ##is my 2 line##'.
APPEND objcont.
CLEAR  objcont.
objcont-line = 'This ##is my 3 line##'.
APPEND objcont.
CLEAR  objcont.
objcont-line = 'This ##is my 4 line##'.
APPEND objcont.
CLEAR  objcont.
objcont-line = 'This ##is my 5 line##'.
APPEND objcont.
CLEAR  objcont.

REPLACE ALL OCCURRENCES OF REGEX '##'
  IN TABLE objcont WITH space.

LOOP AT objcont .
  WRITE / objcont.
ENDLOOP.
Regards, Venkat.O

Read only

0 Likes
2,273

Hi Venkat

That was a good suggestion, I tried your REGEX command but it said "the word regex is reserved"..?

I then tried:

 REPLACE ALL OCCURENCES OF '##' IN OBJCONT-LINE WITH SPACE. 

This gave me SY-SUBRC of 4.

I then tried:

 TRANSLATE OBJCONT-LINE USING '# '. 

This did not return errors but it did not change the contents of the line at all. This is definitely not a normal # symbol we are dealing with...

Read only

0 Likes
2,273

Hi Brad, "the word regex is reserved" ..Is this syntax error or what ? I am able to do in ECC 6.0 . Regards, Venkat.O

Read only

0 Likes
2,273

Yes a syntax error, I am on ECC 5

Read only

0 Likes
2,273

hi,

I also ran into the same problem about yours.

My system runs on ECC 5.0

please refer my post:

[|]

any idea would be appreciated.

Chan Chih-Chieh

Read only

0 Likes
2,273

This will work.

    1. is Line Feed Character


REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>CR_LF IN wa_objcont-line WITH ' '.

Read only

Former Member
0 Likes
2,273

Also just to clarify other things I have tried...

I thought it may have something to do with the character field being 255 characters. So I took the first 72 characters and placed in another temporary field and tried to remove the '#' symbols from the new 72 character field. Still no success...

Declaring new fields with # symbol works fine though and allows removal.

Read only

Former Member
0 Likes
2,273

Anyone else have any ideas?

Would be greatly appreciated.

Thanks...

Read only

0 Likes
2,273

Hi Brad, Try this. It is working.


REPORT  zvenkat_notepad2.

DATA objcont LIKE soli  OCCURS 0 WITH HEADER LINE.

objcont-line = 'This ##is my 1 line##'.
APPEND objcont.
CLEAR  objcont.
objcont-line = 'This ##is my 2 line##'.
APPEND objcont.
CLEAR  objcont.
objcont-line = 'This ##is my 3 line##'.
APPEND objcont.
CLEAR  objcont.
objcont-line = 'This ##is my 4 line##'.
APPEND objcont.
CLEAR  objcont.
objcont-line = 'This ##is my 5 line##'.
APPEND objcont.
CLEAR  objcont.

DATA: offset TYPE i.

LOOP AT objcont .
  REPLACE ALL OCCURRENCES OF '##' IN SECTION LENGTH 255 OF  objcont WITH ''.
  MODIFY objcont INDEX sy-tabix.
  CLEAR   objcont.
ENDLOOP.

LOOP AT objcont .
WRITE / objcont.
ENDLOOP.
regards, Venkat..O

Read only

0 Likes
2,273

Hi Venkat

This didn't work for me either, I am thinking this is a special character passed from the SO_OBJECT_READ function. However I have managed to get a temporary solution working, the problem is I can not determine where the new line begins as no commands are processing the ## symbols.

Read only

0 Likes
2,273

I have also found that if I write to my ZTABLE and try to select from the ZTABLE using ## as my selection criteria it does not find the records.

This raises a new question.. What does ## mean when coming from the Database? Is this some sort of Unicode conversion? I think it is just a placeholder for a CRLF.

Read only

Former Member
0 Likes
2,273

I ended up processing it by writing the character to db table then referencing it. I think that it was a hex character and their is a class which can process this character but I didn't research any further.