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

Reg : code

Former Member
0 Likes
466

Hi Experts ,

im having doubt in small code ..

actual the material no is UM529063 , when i try to execute the report it has to fetch all the material that are started with UM, AND THEN IT HAS TO DISPLAY LIKE THIS : UM-529063. Separating the first twoletters with Hyphen..

but its not giving the ouput .

Please check the code and do the neccessary changes :

TABLES : MARA.

TYPES : BEGIN OF TP_MARA,

MATNR TYPE MARA-MATNR ,

MEINS TYPE MARA-MEINS ,

END OF TP_MARA.

DATA: T_MARA TYPE STANDARD TABLE OF TP_MARA .

DATA : WA_MARA TYPE TP_MARA.

DATA : WW_MATNR TYPE MARA-MATNR .

SELECT-OPTIONS : P_MATNR FOR WW_MATNR.

START-OF-SELECTION.

SELECT MATNR MEINS FROM MARA INTO TABLE T_MARA

WHERE MATNR IN P_MATNR.

IF T_MARA IS NOT INITIAL.

PERFORM MURTHY.

ENDIF.

&----


*& Form MURTHY

&----


  • text

----


FORM MURTHY.

DATA : W_matnr1(2) ,

W_matnr2(16),

W_MATNR(18) .

IF WA_MARA-MATNR CP 'MI*'.

W_matnr1 = WA_MARA-matnr+0(2).

W_matnr2 = WA_MARA-matnr+2(16).

concatenate W_matnr1 W_matnr2 into W_matnr separated by '-'.

WRITE : / W_MATNR.

APPEND WA_MARA TO T_MARA.

ENDIF.

ENDFORM. "MURTHY

3 REPLIES 3
Read only

Former Member
0 Likes
432

Hi Narayana murthy,

use

concatenate W_matnr1 '-' W_matnr2 into W_matnr.

Regards

Arun

Read only

Former Member
0 Likes
432

Hi narayana,

I would replace "T_MARA" for "T_MARA[]" in order to check if it's initial. And I would remove the material number check in the perform.

I hope it helps. Best regards,

Alvaro


TABLES : MARA.

TYPES : BEGIN OF TP_MARA,
MATNR TYPE MARA-MATNR ,
MEINS TYPE MARA-MEINS ,
END OF TP_MARA.

DATA: T_MARA TYPE STANDARD TABLE OF TP_MARA .
DATA : WA_MARA TYPE TP_MARA.

DATA : WW_MATNR TYPE MARA-MATNR .

SELECT-OPTIONS : P_MATNR FOR WW_MATNR.

START-OF-SELECTION.
SELECT MATNR MEINS FROM MARA INTO TABLE T_MARA
WHERE MATNR IN P_MATNR.

*IF T_MARA IS NOT INITIAL.   "delete
IF T_MARA[] IS NOT INITIAL.  "insert
PERFORM MURTHY.
ENDIF.

*&--------------------------------------------------------------------*
*& Form MURTHY
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM MURTHY.

DATA : W_matnr1(2) ,
W_matnr2(16),
W_MATNR(18) .

*IF WA_MARA-MATNR CP 'MI*'.  "delete

W_matnr1 = WA_MARA-matnr+0(2).
W_matnr2 = WA_MARA-matnr+2(16).

concatenate W_matnr1 W_matnr2 into W_matnr separated by '-'.

WRITE : / W_MATNR.
APPEND WA_MARA TO T_MARA.

ENDIF.
ENDFORM. "MURTHY 

Read only

RaymondGiuseppi
Active Contributor
0 Likes
432

Look at data element MATNR, there could be a conversion exit (like MATN2 or so depending on Customizing), so MATNR doesnt display its internal value, you should WRITE MATNR into a text field and then split at "MI".

Regards