Application Development 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: 

Extracting material from a string

0 Kudos

Hello everyone,

I am selecting from workflow table (swwwihead). In the field  wi_text, there is a detailed description of the workflow message.

Examples:

317837-0010: US10: Ready for Dchain 03

17627 : IN10 : System Error - DChain 10 Not Set

358094-045 : AU10 : System Error - DChain 10 Not Set

If you notice, we have material numbers of all different lengths. Does anyone know if SAP has any standard functionality (FM or BAPI or built in function) to pass a string and extract the material number in that string? Or know of a workflow table other than swwwihead that may have this information?

I am currently parsing the string first assuming it is a 10 digit material.

I then am using the BAPI BAPI_MATERIAL_EXISTENCECHECK to see if the material exists in our system

If it doesn't I parse the string down 1 character and run the BAPI again, etc.

This is obviously not an ideal solution so was wondering if anyone had any better ideas.

I have searched around but haven't had any luck.

Thank you!

1 ACCEPTED SOLUTION

VenkatRamesh_V
Active Contributor
0 Kudos

Hi Jess,

Try.

If the material value  will be stored  as first in the entries then you fix the size to be 14 (mara-matnr length), separate the special symbols(:) using  split  or

use.

TABLES: mara.

DATA: lv_text TYPE string VALUE '317837-0010: US10: Ready for Dchain 03',

       itab  TYPE TABLE OF string,

       wa    LIKE LINE OF  itab.

SPLIT lv_text AT ':' INTO TABLE itab.

loop at itab INTO wa.

CONDENSE wa NO-GAPS.

SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr = wa.

IF sy-subrc  IS INITIAL.

MESSAGE 'Material Exit' TYPE 'S'.

EXIT.

ENDIF.

ENDLOOP.


Hope it helpful,


Regards,

Venkat.

2 REPLIES 2

VenkatRamesh_V
Active Contributor
0 Kudos

Hi Jess,

Try.

If the material value  will be stored  as first in the entries then you fix the size to be 14 (mara-matnr length), separate the special symbols(:) using  split  or

use.

TABLES: mara.

DATA: lv_text TYPE string VALUE '317837-0010: US10: Ready for Dchain 03',

       itab  TYPE TABLE OF string,

       wa    LIKE LINE OF  itab.

SPLIT lv_text AT ':' INTO TABLE itab.

loop at itab INTO wa.

CONDENSE wa NO-GAPS.

SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr = wa.

IF sy-subrc  IS INITIAL.

MESSAGE 'Material Exit' TYPE 'S'.

EXIT.

ENDIF.

ENDLOOP.


Hope it helpful,


Regards,

Venkat.

0 Kudos

Thank you, this worked great!