2021 Jan 19 11:46 AM
TYPES:
BEGIN OF GTS_VAL,
BUKRS TYPE ZMM0011T-BUKRS,
MATNR TYPE MARA-MATNR,
MATNR_TMP TYPE MARC-MATNR,
BWKEY TYPE T001W-BWKEY,
WERKS TYPE T001W-WERKS,
END OF GTS_VAL.
GTT_VAL TYPE STANDARD TABLE OF GTS_VAL.
Data:
GDT_R_DATE type range of sy-datlo.
GDT_STARTDAY TYPE MSEG-BUDAT_MKPT
GDT_STARTDAY1 TYPE MSEG-BUDAT_MKPF.
GDT_LASTDAY TYPE MSEG-BUDAT_MKPF.
LDT_VAL TYPE GTT_VAL.
*First day of period
CONCATENATE S_ZYEAR-LOW '01' INTO GDF_STARTDAY1.
CONCATENATE S_ZYEAR-HIGH '01' INTO GDF_STARTDAY.
*Last day of period
Call function 'LAST_DAY_OF_MONTHS'.
EXPORTING
DAY_IN = GDF_STARTDAY
IMPORTING
LAST_DAY_OF_MONTH = GDF_LASTDAY
EXCEPTION
~
GDF_R_DATE = VALUE #( BASE GDF_R_DATE ( SIGN = 'I' OPTION = 'BT' LOW = GDF_STARTDAY1 HIGH = GDF_LASTDAY ) ).
SELECT ZMM0011T~EBELN,
ZMM0011T~EBELP,
ZMM0011T~MENGE_GR,
ZMM0011T~DMBST_GR
FROM ZMM0011T
WHERE BUKRS = @P_BUKRS
INTO TABLE = @GDT_ZMM0011T
SELECT MSEG~BWART,
MSEG~DMBTR,
MSEG~BNBTR,
MSEG~SHKZG,
MSEG~MENGE,
MSEG~EBELN,
MSEG~EBELP,
EKPO~PSTYP,
EKPO~MENGE,
EKPO~KNTTP,
T156~SHKZG,
T156~XSTBW
FROM MSEG
INNER JOIN EKPO
ON EKPO~EBELN = MSEG~EBELN
AND EKPO~EBELP = MSEG~EBELP
AND EKPO~KNTTP = ' '
INNER JOIN T156
ON T156~BWART = MSEG~BWART
FOR ALL ENTRIES IN
@LDT_VAL
WHERE MSEG~MATNR = @LDT_VAL-MATNR
AND MSEG~WERKS = @LDT_VAL-WERKS
AND MSEG~BUKRS = @P_BUKRS
INTO TABLE @GDT_MSEG.
2021 Jan 19 12:39 PM
SY-SUBRC = 4 means that no records was found in the database for those conditions. Please refer to ABAP documentation.
If that was your question... Or if you need help to figure out why there is nothing found, we need more information as the data in the transaction tables obviously is different in different systems. And we're not seeing your entire code.
I suggest you look for yourself in SE16N to see if the data is really there in the way you expect it. And minding the joins.
2021 Jan 19 11:48 AM
Hi!
I tested the SQL from MSEG , and SY-SUBRC = 4. I don't why.
Can anyone here help me?
Please.
2021 Jan 19 12:39 PM
SY-SUBRC = 4 means that no records was found in the database for those conditions. Please refer to ABAP documentation.
If that was your question... Or if you need help to figure out why there is nothing found, we need more information as the data in the transaction tables obviously is different in different systems. And we're not seeing your entire code.
I suggest you look for yourself in SE16N to see if the data is really there in the way you expect it. And minding the joins.