SELECTION-SCREEN: BEGIN OF BLOCK dba WITH FRAME TITLE text-001.
SELECT-OPTIONS: matnr FOR mara-matnr,
werks FOR t001w-werks MEMORY ID wrk,
charg FOR msku-charg,
kunnr FOR msku-kunnr.
PARAMETERS: sobkz_w LIKE am07m-kukns AS CHECKBOX DEFAULT 'X',
sobkz_v LIKE am07m-lhgut AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN: END OF BLOCK dba.
SELECTION-SCREEN: BEGIN OF BLOCK anz WITH FRAME TITLE text-005.
PARAMETERS: alv_def LIKE disvariant-variant,
zero LIKE am07m-xmnul AS CHECKBOX.
SELECTION-SCREEN: END OF BLOCK anz.
INCLUDE rm07alvi.
DATA: BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE msku.
DATA: maktx LIKE makt-maktx,
name1_w LIKE t001w-name1,
name1_k LIKE kna1-name1,
meins LIKE mara-meins,
dummy TYPE alv_dummy,
farbe TYPE slis_t_specialcol_alv, " color
kunres LIKE mbew-salk3, "total unrestricted stock
kinqul LIKE mbew-salk3, "total in quality inspection
krest LIKE mbew-salk3. "total restricted stock
ctotal LIKE mbew-salk3.
DATA: END OF itab.
DATA: BEGIN OF list OCCURS 0.
INCLUDE STRUCTURE itab.
DATA: END OF list.
DATA: BEGIN OF header OCCURS 0,
kunnr LIKE kna1-kunnr,
name1_k LIKE kna1-name1,
ctotal LIKE mbew-salk3,
END OF header.
DATA: fc TYPE slis_fieldcat_alv OCCURS 0 WITH HEADER LINE.
DATA: detail.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR alv_def.
PERFORM alv_f4.
AT SELECTION-SCREEN.
CALL FUNCTION 'MMIM_ENTRYCHECK_MAIN'
TABLES
it_matnr = matnr
it_werks = werks
it_kunnr = kunnr.
IF sobkz_w = space AND sobkz_v = space.
message changed from e159(at) to e831 "XJD 14.11.2001
SET CURSOR FIELD 'SOBKZ_W'. "XJD 14.11.2001
MESSAGE e831. "Please choose at least one stock type
ENDIF.
PERFORM alv_check.
************************************************************************
FORM data_selection.
DATA: BEGIN OF makt_key OCCURS 0,
matnr LIKE makt-matnr,
END OF makt_key.
DATA: BEGIN OF imakt OCCURS 0,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
END OF imakt.
DATA: BEGIN OF mara_key OCCURS 0,
matnr LIKE mara-matnr,
END OF mara_key.
DATA: BEGIN OF imara OCCURS 0,
matnr LIKE mara-matnr,
meins LIKE mara-meins,
END OF imara.
DATA: BEGIN OF t001w_key OCCURS 0,
werks LIKE t001w-werks,
END OF t001w_key.
DATA: BEGIN OF it001w OCCURS 0,
werks LIKE t001w-werks,
name1 LIKE t001w-name1,
END OF it001w.
DATA: BEGIN OF kna1_key OCCURS 0,
kunnr LIKE kna1-kunnr,
END OF kna1_key.
DATA: BEGIN OF ikna1 OCCURS 0,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-name1,
END OF ikna1.
New table to hold the costs
DATA: BEGIN OF imbew_key OCCURS 0,
charg LIKE mchb-charg,
END OF imbew_key.
DATA: BEGIN OF imbew OCCURS 0,
matnr LIKE mbew-matnr,
bwkey LIKE mbew-bwkey,
salk3 LIKE mbew-salk3,
charg LIKE mchb-charg,
END OF imbew.
DATA: imbew TYPE STANDARD TABLE OF smbew.
RANGES sobkz FOR msku-sobkz.
Main data
REFRESH sobkz.
sobkz-sign = 'I'. sobkz-option = 'EQ'.
IF sobkz_w = 'X'. sobkz-low = 'W'. APPEND sobkz. ENDIF.
IF sobkz_v = 'X'. sobkz-low = 'V'. APPEND sobkz. ENDIF.
SELECT * FROM msku INTO CORRESPONDING FIELDS OF TABLE itab
WHERE matnr IN matnr
AND werks IN werks
AND charg IN charg
AND sobkz IN sobkz
AND kunnr IN kunnr.
READ TABLE makt_key INDEX 1.
IF sy-subrc = 0.
SELECT matnr maktx INTO CORRESPONDING FIELDS OF TABLE imakt
FROM makt FOR ALL ENTRIES IN makt_key
WHERE matnr = makt_key-matnr
AND spras = sy-langu.
SORT imakt BY matnr.
ENDIF.
READ TABLE mara_key INDEX 1.
IF sy-subrc = 0.
SELECT matnr meins INTO CORRESPONDING FIELDS OF TABLE imara
FROM mara FOR ALL ENTRIES IN mara_key
WHERE matnr = mara_key-matnr.
SORT imara BY matnr.
ENDIF.
READ TABLE t001w_key INDEX 1.
IF sy-subrc = 0.
SELECT werks name1 INTO CORRESPONDING FIELDS OF TABLE it001w
FROM t001w FOR ALL ENTRIES IN t001w_key
WHERE werks = t001w_key-werks.
SORT it001w BY werks.
**new code to get costs
*selecting data into imbew, later reading imbew based on batch number
and placing the necessary values in the final structure itab-.
SELECT a~matnr a~bwkey a~salk3 b~charg INTO TABLE imbew
FROM mbew AS a
JOIN mchb AS b
ON a~matnr = b~matnr AND
a~bwkey = b~werks
FOR ALL ENTRIES IN imbew_key
WHERE b~charg = imbew_key-charg AND
a~bwkey = t001w_key-werks.
SORT imbew BY matnr bwkey charg.
ENDIF.
READ TABLE kna1_key INDEX 1.
IF sy-subrc = 0.
SELECT kunnr name1 INTO CORRESPONDING FIELDS OF TABLE ikna1
FROM kna1 FOR ALL ENTRIES IN kna1_key
WHERE kunnr = kna1_key-kunnr.
SORT ikna1 BY kunnr.
ENDIF.
LOOP AT itab.
READ TABLE imakt WITH KEY matnr = itab-matnr BINARY SEARCH.
IF sy-subrc = 0. itab-maktx = imakt-maktx. ENDIF.
READ TABLE imara WITH KEY matnr = itab-matnr BINARY SEARCH.
IF sy-subrc = 0. itab-meins = imara-meins. ENDIF.
READ TABLE it001w WITH KEY werks = itab-werks BINARY SEARCH.
IF sy-subrc = 0. itab-name1_w = it001w-name1. ENDIF.
READ TABLE ikna1 WITH KEY kunnr = itab-kunnr BINARY SEARCH.
IF sy-subrc = 0. itab-name1_k = ikna1-name1. ENDIF.
*new code
*get data from imbew to final structure
************************************************************************
FORM calculate_and_colorize.
DATA: sum LIKE msku-kulab,
cust_sum LIKE mbew-salk3.
REFRESH list.
************************************************************************
FORM set_status USING rt_extab TYPE slis_t_extab.
DATA: wa TYPE slis_extab.
IF cl_mmim_auth=>level( ) IS INITIAL.
APPEND 'AUTH' TO rt_extab.
ENDIF.
IF cl_mmim_auth=>level( ) = cl_mmim_auth=>c_error.
MESSAGE s124(m7).
ENDIF.
Deactivate detail list if in detail list
IF detail = 'X'.
wa-fcode = 'DETAIL'.
APPEND wa TO rt_extab.
ENDIF.
SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.
ENDFORM. "set_status
************************************************************************
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs TYPE slis_selfield.
Call from detail list: Change tablename
IF rs-tabname = '1'.
rs-tabname = 'LIST'.
ENDIF.
Read the correct table
CLEAR: list, header.
CASE rs-tabname.
WHEN 'HEADER'.
READ TABLE header INDEX rs-tabindex.
MOVE-CORRESPONDING header TO list.
WHEN 'LIST'.
READ TABLE list INDEX rs-tabindex.
ENDCASE.
CHECK sy-subrc = 0.
Double click targets
IF rf_ucomm = '&IC1'.
CASE rs-tabname.
WHEN 'HEADER'.
rf_ucomm = 'ADDR'.
WHEN 'LIST'.
CASE rs-fieldname.
WHEN 'MATNR'.
rf_ucomm = 'MMBE'.
WHEN OTHERS.
rf_ucomm = 'DOCU'.
ENDCASE.
ENDCASE.
ENDIF.
Commands
CASE rf_ucomm.
WHEN 'MMBE'.
CHECK rs-tabname = 'LIST'. "only for items
SET PARAMETER ID 'MAT' FIELD list-matnr.
SET PARAMETER ID 'WRK' FIELD list-werks.
CALL TRANSACTION 'MMBE' AND SKIP FIRST SCREEN.
WHEN 'DOCU'.
CHECK rs-tabname = 'LIST'.
SUBMIT rm07docs WITH matnr = list-matnr
WITH werks = list-werks
WITH charg = list-charg
WITH sobkz = list-sobkz
WITH kunnr = list-kunnr
AND RETURN.
WHEN 'ADDR'.
SET PARAMETER ID 'KUN' FIELD list-kunnr.
CALL TRANSACTION 'VD03' AND SKIP FIRST SCREEN.
WHEN 'AUTH'.
CALL METHOD cl_mmim_auth=>display.
WHEN 'DETAIL'.
PERFORM detail_list.
ENDCASE.
CLEAR rf_ucomm.
ENDFORM. "user_command
************************************************************************
FORM detail_list.
DATA: fc_detail TYPE slis_fieldcat_alv OCCURS 0 WITH HEADER LINE.
DATA: variant_detail LIKE disvariant.
DATA: lt_base_list LIKE list[]. "401421
The detail ALV may modify the list (sorting). If returned to the
base list, the original list needs to be restored.
lt_base_list] = list[. "401421
REFRESH fc_detail.
LOOP AT fc.
MOVE-CORRESPONDING fc TO fc_detail.
CLEAR fc_detail-tabname.
APPEND fc_detail.
ENDLOOP.
CLEAR variant_detail.
variant_detail-report = alv_repid.
variant_detail-handle = 'DETA'.
detail = 'X'. "needed for GUI status differentiation
--> p1 text
<-- p2 text
FORM convert_to_ea .
DATA: l_lvsme TYPE lvs_lvsme,
l_lgnum TYPE lgnum,
l_lbkum TYPE lbkum,
l_salk3 TYPE salk3,
l_peinh TYPE peinh,
l_verpr TYPE verpr,
l_bwtty TYPE bwtty_d,
factor TYPE f.
l_lgnum = list-werks+1.
SELECT SINGLE lvsme
INTO l_lvsme
FROM mlgn
WHERE matnr = list-matnr
AND lgnum = l_lgnum.
*...for Standard materials...
SELECT SINGLE lbkum salk3 peinh verpr bwtty
INTO (l_lbkum, l_salk3, l_peinh, l_verpr, l_bwtty)
FROM mbew
WHERE matnr = list-matnr
AND bwkey = list-werks.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.