cancel
Showing results for 
Search instead for 
Did you mean: 

How to get unique thread number for sales order line item text using Read_Text in ABAP?

0 Kudos

In BW, we have scenario where we need to get unique thread numbers from "Logo / Embroidery text " field for a sales order line item in VA03 in SAP. So, I created DSO for this and had sales order, sales order line item, and thread numbers as key and used READ_TEXT Function Module to get text information.

Since I had to get multiple lines of text, used loop statement in below code to get multiple order line item text data. It works fine, but the actual request is to get only the unique thread numbers from the order line item text. In screenshot above, we need to get only 1801, and 1675 as thread numbers for this line item. But my code for this thread number field gets data from * --BEGIN THREAD until *-- END THREAD MAP. Should we use Contains String (CS) in ABAP to get only the thread numbers? Even if we do that, how do we get only the unique thread numbers?

Ultimately, the data should look like this:

Sales order Line item Thread Number

39541745 10 1801

39541745 10 1675

Below is the code I am using in field routine in DSO using READ_TEXT FM to get this text data.

TYPES: BEGIN OF ty_ZSDO120,
DOC_NUMBER TYPE /BI0/OIDOC_NUMBER,
S_ORD_ITEM TYPE /BI0/OIS_ORD_ITEM,
END OF ty_ZSDO120.

DATA: i_lines type STANDARD TABLE OF tline,
ls_lines type tline.

DATA: w_tdname TYPE stxh-tdname.

DATA: v_text type string.

CLEAR w_tdname.
CONCATENATE SOURCE_FIELDS-DOC_NUMBER SOURCE_FIELDS-S_ORD_ITEM
INTO w_tdname.

* Read Order Line Item Logo / Embroidery Text
CLEAR: i_lines.
REFRESH: i_lines.


*
CALL FUNCTION 'READ_TEXT'
EXPORTING
language = sy-langu
id = 'ZLGO'
name = w_tdname
object = 'VBBP'
TABLES
lines = i_lines
EXCEPTIONS
id = 01
language = 02
name = 03
not_found = 04
object = 05
reference_check = 06.



Loop at i_lines into ls_lines.

if sy-tabix = 1.

move ls_lines-tdline to v_text.

else.

concatenate v_text ls_lines-tdline into v_text separated by space.

endif.

endloop.

RESULT = v_text.

Please let me know how to achieve this in BW DSO. Also attached in my DSO screenshot.

srikanthnalluri
Active Participant
0 Kudos

May be you can take that records into an ITAB, like (VBELN, POSNR, THREAD) and do DELETE DUPLICATES BY THREAD.

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Thanks for the response, but as I mentioned we are just looking to get thread numbers here..which would be Numbers from the screenshot like 1801, 1675. This is the business requirement and they want to see these numbers, so we do not have a call why they want it this way.

The pattern is to look for a line that starts with *ZDMS_STOP* and grab the number after this line, example: 1801. Grab all numbers after every ZDMS_STOP and then remove duplicates. How do I achieve that?

Jelena
Active Contributor
0 Kudos

To start off, it's not a good idea to use texts to store any important information. These are good for, say, storing customer service notes or adding random comments to the forms sent to the customers and such. Important business data - not so much. Especially when it comes to reporting. I've seen this mistake made too many times, unfortunately.

Regarding specific technical challenge, this is one of those Alice in Wonderland type question: to find a road somewhere you need to know where you want to get to first. This is just plain text, how do you know which numbers are "thread numbers"?

In order for a program to find something, there must be some algorithm, some pattern. What is a pattern in your case? Look for a line that starts with ZDMS_STOP... and then look for a number at the end of the line? Is this just space separated data? What else could there be instead of ZDMS_STOP... That's what you'd need to know in order to write a program to parse this data.

After that removing duplicates from internal table is a trivial task. READ_TEXT part is correct.