on 2025 Feb 24 9:17 AM
This is my abap code block
DATA: it_fg_code TYPE TABLE OF mast-matnr, " Table to store FG Codes
matnr1 TYPE mast-matnr. " Variable for single FG Code
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.
SELECT-OPTIONS material FOR mast-matnr.
SELECT-OPTIONS plant FOR mast-werks.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
" Step 1: Fetch FG Code from MAST table for material type 'FERT'
SELECT DISTINCT mast~matnr
INTO TABLE IT_MTYPE1
FROM mast
INNER JOIN mara ON mast~matnr = mara~matnr
WHERE mast~matnr IN material
AND mara~MTART = 'FERT'.
" Step 2: Fetch details from MAST, STPO, and MAKt for materials and their exploded parts
SELECT mast~werks
mast~stlnr
mast~matnr
makt~maktx
idnrk
stpo~menge
INTO CORRESPONDING FIELDS OF TABLE itm_details
FROM mast AS mast
INNER JOIN stpo AS stpo ON mast~stlnr = stpo~stlnr
INNER JOIN makt AS makt ON mast~matnr = makt~matnr
WHERE mast~matnr IN material
AND werks IN plant
AND stpo~stlty = 'M'
AND mast~stlal = mast~stlal.
IF NOT itm_details[] IS INITIAL.
" Step 3: Fetch location data
SELECT matnr
werks
lgpro
INTO CORRESPONDING FIELDS OF TABLE it_loc
FROM marc
FOR ALL ENTRIES IN itm_details
WHERE werks = itm_details-werks
AND matnr = itm_details-matnr.
ENDIF.
IF NOT itm_details[] IS INITIAL.
" Step 4: Fetch verification data for the materials
SELECT mast~matnr
mast~werks
verid
bdatu
adatu
mkal~stlal
bstma
idnrk
INTO CORRESPONDING FIELDS OF TABLE it_ver
FROM mast AS mast
INNER JOIN mkal AS mkal ON mast~matnr = mkal~matnr
INNER JOIN stpo AS stpo ON mast~stlnr = stpo~stlnr
FOR ALL ENTRIES IN itm_details
WHERE mast~werks = itm_details-werks
AND mast~matnr = itm_details-matnr.
ENDIF.
* Step 5: Loop through itm_details and update FG Code for 'FERT' type materials
LOOP AT itm_details INTO DATA(ls_item).
" Check if material type is 'FERT' by checking against IT_MTYPE1
READ TABLE it_mtype1 INTO matnr1 WITH KEY matnr = ls_item-matnr.
IF sy-subrc = 0.
" Assign FG Code to the structure only for 'FERT' materials
ls_item-fg_code = matnr1. " Assign FG Code to the structure
ELSE.
" For exploded parts, set FG code to blank or empty
ls_item-fg_code = ''. " No FG code for exploded parts
ENDIF.
The above mentioned code is displaying this output
I want on the FERT codes to be displayed against it.
Request clarification before answering.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.