*&---------------------------------------------------------------------*
*& TABLES
*&---------------------------------------------------------------------*
TABLES:T001,
TKA02,
TKKAP,
LTDX,
TKV09,
AUFK,
AFKO,
AFPO,
SSCRFIELDS,
T001K.
*&---------------------------------------------------------------------*
*& G L O B L E V A R I A B L E
*&---------------------------------------------------------------------*
TYPE-POOLS ICON.
*DATA FUNCTXT TYPE SMP_DYNTXT.
DATA: TXTW(45) TYPE C.
DATA:LD_RFCGR TYPE SPTA_RFCGR,
SD_TEXT_NGW(30) TYPE C.
DATA: RFCGR_DISPLAYFORMAT TYPE N VALUE '0'.
DATA:T_BUKRS TYPE BUKRS,
T_BWKEY TYPE BWKEY,
T_KOKRS TYPE KOKRS,
T_FIRST_DAY LIKE AFRU-BUDAT,
T_LAST_DAY LIKE AFRU-BUDAT.
DATA: T_BDC LIKE TABLE OF BDCDATA WITH HEADER LINE.
DATA: T_MSG TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE.
DATA: JOBNAME LIKE TBTCJOB-JOBNAME VALUE
'TRANSFER DATA'.
DATA: JOBCOUNT LIKE TBTCJOB-JOBCOUNT,
HOST LIKE MSXXLIST-HOST.
DATA: BEGIN OF STARTTIME.
INCLUDE STRUCTURE TBTCSTRT.
DATA: END OF STARTTIME.
DATA: STARTTIMEIMMEDIATE LIKE BTCH0000-CHAR1 VALUE 'X'.
*----------------------------------------------------------------------*
* INTERNAL TABLE
*----------------------------------------------------------------------*
DATA: IT_TRACE LIKE JSTO_PRE OCCURS 0 WITH HEADER LINE.
DATA:BEGIN OF ORDER_TAB OCCURS 0,
AUFNR LIKE AUFK-AUFNR,
WERKS LIKE AUFK-WERKS,
APRIO LIKE AFKO-APRIO,
MATNR LIKE AFPO-MATNR,
END OF ORDER_TAB.
DATA:BEGIN OF ORDER_HEAD OCCURS 0,
AUFNR LIKE AFKO-AUFNR,
APRIO LIKE AFKO-APRIO,
END OF ORDER_HEAD.
*DATA: BEGIN OF WA_MAT_HIER OCCURS 0,
* MATNR TYPE MATNR,
* /EPCOS/TDKKL TYPE /EPCOS/TDK_GRP,
* SEGMENT TYPE FB_SEGMENT,
* ORG_LV3 TYPE SETID,
* ORG_LV4 TYPE SETID,
* END OF WA_MAT_HIER.
DATA: BEGIN OF WA_MAT_HIER OCCURS 0.
INCLUDE STRUCTURE /TDK/SC0002.
DATA: END OF WA_MAT_HIER.
DATA: T_MATNR LIKE STANDARD TABLE OF /TDK/SC0001, "input parameter
WA_MATNR LIKE LINE OF T_MATNR.
DATA: T_MAT_HIER TYPE STANDARD TABLE OF /TDK/SC0002, "hierarchy
TH_MAT_HIER TYPE /TDK/SC0002. "header of hierarchy
DATA:BEGIN OF ITAB OCCURS 0,
ORG_LV3 TYPE SETID,
ORG_LV4 TYPE SETID,
SEGMENT TYPE FB_SEGMENT,
/EPCOS/TDKKL TYPE /EPCOS/TDK_GRP,
AUFNR LIKE AUFK-AUFNR,
WERKS LIKE AUFK-WERKS,
APRIO LIKE AFKO-APRIO,
MATNR LIKE AFPO-MATNR,
END OF ITAB.
RANGES:S_AUFNR FOR ITAB-AUFNR.
RANGES:S_WERKS FOR ITAB-WERKS.
*&---------------------------------------------------------------------*
*& SELECT-SCREEN
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B0 WITH FRAME TITLE TEXT-000.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS:P_BUKRS LIKE T001-BUKRS OBLIGATORY.
SELECT-OPTIONS: P_WERKS FOR T001K-BWKEY NO INTERVALS.
PARAMETERS:P_BU(34) TYPE C,
P_CBU(34) TYPE C,
P_SBU TYPE FB_SEGMENT,
P_PRCTR LIKE AUFK-PRCTR,
P_GROUP TYPE /EPCOS/TDK_GRP.
SELECTION-SCREEN :SKIP.
PARAMETERS:P_GJAHR TYPE GJAHR OBLIGATORY,
P_MONAT TYPE MONAT OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS: C1 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X',
C2 AS CHECKBOX USER-COMMAND CHECK ,
C3 AS CHECKBOX USER-COMMAND CHECK .
SELECTION-SCREEN :SKIP.
SELECT-OPTIONS: P_APRIO FOR AFKO-APRIO NO INTERVALS.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
PARAMETERS: R1 TYPE C RADIOBUTTON GROUP RGR1 DEFAULT 'X'
USER-COMMAND RAD_CLICK ,
R2 TYPE C RADIOBUTTON GROUP RGR1,
R3 TYPE C RADIOBUTTON GROUP RGR1.
SELECTION-SCREEN END OF BLOCK B3.
PARAMETERS: C4 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK B0.
SELECTION-SCREEN :SKIP.
**Work in Process: List
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 1(50) BUT1 USER-COMMAND BUTTON1 VISIBLE LENGTH 2.
SELECTION-SCREEN COMMENT 6(50) COM1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-007 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_1 RADIOBUTTON GROUP RGR3 MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(30) TEXT-010 FOR FIELD R1_1 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_2 RADIOBUTTON GROUP RGR3 MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(10) TEXT-011 FOR FIELD R1_2 MODIF ID BL1.
PARAMETERS:P_VERSA LIKE TKKAP-VERSA MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-008 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_C AS CHECKBOX USER-COMMAND CHECK MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(30) TEXT-012 FOR FIELD R1_C MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-009 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_C1 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X' MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(30) TEXT-013 FOR FIELD R1_C1 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_C2 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL1 .
SELECTION-SCREEN COMMENT 6(30) TEXT-014 FOR FIELD R1_C2 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_C3 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(30) TEXT-015 FOR FIELD R1_C3 MODIF ID BL1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN :SKIP.
PARAMETERS:P_VAR LIKE LTDX-VARIANT MODIF ID BL1.
SELECTION-SCREEN END OF BLOCK B4.
SELECTION-SCREEN :SKIP.
**Variances: Manufacturing Orders and Product Cost Collectors
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 1(50) BUT2 USER-COMMAND BUTTON2 VISIBLE LENGTH 2.
SELECTION-SCREEN COMMENT 6(60) COM2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-005.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-007 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL2.
PARAMETERS: R2_1 RADIOBUTTON GROUP RGR4 MODIF ID BL2.
SELECTION-SCREEN COMMENT 6(30) TEXT-016 FOR FIELD R2_1 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL2.
PARAMETERS: R2_2 RADIOBUTTON GROUP RGR4 MODIF ID BL2.
SELECTION-SCREEN COMMENT 6(20) TEXT-017 FOR FIELD R2_2 MODIF ID BL2.
PARAMETERS:P_AWVRS LIKE TKV09-AWVRS MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-008 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL2.
PARAMETERS: R2_C1 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL2.
SELECTION-SCREEN COMMENT 6(30) TEXT-018 FOR FIELD R2_C1 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL2.
PARAMETERS: R2_C2 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X' MODIF ID BL2.
SELECTION-SCREEN COMMENT 6(30) TEXT-019 FOR FIELD R2_C2 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B5.
SELECTION-SCREEN :SKIP.
**Settlement: Production Orders and Product Cost Collectors
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 1(50) BUT3 USER-COMMAND BUTTON3 VISIBLE LENGTH 2.
SELECTION-SCREEN COMMENT 6(60) COM3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK B6 WITH FRAME TITLE TEXT-006.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-007 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
PARAMETERS: P_VAART TYPE CO_VAART DEFAULT '1' MODIF ID BL3,
P_PERIO TYPE COBU_PERIO MODIF ID BL3.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-022 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_1 RADIOBUTTON GROUP RGR5 MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(30) TEXT-023 FOR FIELD R3_1 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_2 RADIOBUTTON GROUP RGR5 MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(20) TEXT-024 FOR FIELD R3_2 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-008 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_C1 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X' MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(30) TEXT-025 FOR FIELD R3_C1 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_C2 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(30) TEXT-026 FOR FIELD R3_C2 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_C3 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(30) TEXT-027 FOR FIELD R3_C3 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-009 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: LIST LIKE LKO74-LIST MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(10) TEXT-028 FOR FIELD LIST MODIF ID BL3.
SELECTION-SCREEN PUSHBUTTON 33(30) PU_LIST USER-COMMAND LIST MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
* technical fields -> no output because on pushbuttons
SELECTION-SCREEN BEGIN OF BLOCK FELDER WITH FRAME .
PARAMETERS: COUNT LIKE LKO74-COUNT_COM DEFAULT '10' NO-DISPLAY MODIF ID BL3.
PARAMETERS: ERRGR LIKE LKO74-AUFGR NO-DISPLAY MODIF ID BL3.
PARAMETERS: RFC_NO LIKE LKO74-RFC_NO NO-DISPLAY MODIF ID BL3.
PARAMETERS: VAR_COS LIKE LKO74-VARIANT_COS NO-DISPLAY MODIF ID BL3,
VAR_WIP LIKE LKO74-VARIANT_WIP NO-DISPLAY MODIF ID BL3.
SELECTION-SCREEN END OF BLOCK FELDER.
SELECTION-SCREEN :SKIP.
SELECTION-SCREEN :SKIP.
* Pushbutton for technical settings
SELECTION-SCREEN PUSHBUTTON 1(30) PU_TECH USER-COMMAND TECH MODIF ID BL3.
SELECTION-SCREEN END OF BLOCK B6.
*&---------------------------------------------------------------------*
*& INITIALIZATION
*&---------------------------------------------------------------------*
INCLUDE RKO74TOP.
INITIALIZATION.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT1 .
COM1 = 'Work in Process: List'.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT2 .
COM2 = 'Variances: Manufacturing Orders and Product Cost Collectors'.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT3 .
COM3 = 'Settlement: Production Orders and Product Cost Collectors'.
PERFORM CHANGE_ICONS.
AT SELECTION-SCREEN.
CASE SY-UCOMM.
WHEN 'BUTTON1'.
IF BUT1 = '@K1@'.
WRITE ICON_DATA_AREA_COLLAPSE AS ICON TO BUT1.
COM1 = 'Work in Process: List'.
ELSE.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT1.
COM1 = 'Work in Process: List'.
ENDIF.
WHEN 'BUTTON2'.
IF BUT2 = '@K1@'.
WRITE ICON_DATA_AREA_COLLAPSE AS ICON TO BUT2.
COM2 = 'Variances: Manufacturing Orders and Product Cost Collectors'.
ELSE.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT2.
COM2 = 'Variances: Manufacturing Orders and Product Cost Collectors'.
ENDIF.
WHEN 'BUTTON3'.
IF BUT3 = '@K1@'.
WRITE ICON_DATA_AREA_COLLAPSE AS ICON TO BUT3.
COM3 = 'Settlement: Production Orders and Product Cost Collectors'.
ELSE.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT3.
COM3 = 'Settlement: Production Orders and Product Cost Collectors'.
ENDIF.
ENDCASE.
PERFORM PUSHBOTTONS.
PERFORM CHANGE_ICONS.
PERFORM CHECK_VALUE.
PERFORM PRE_DATA .
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF BUT1 = '@K2@' AND SCREEN-GROUP1 = 'BL1'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
IF BUT2 = '@K2@' AND SCREEN-GROUP1 = 'BL2'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
IF BUT3 = '@K2@' AND SCREEN-GROUP1 = 'BL3'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
LOOP AT SCREEN .
IF SCREEN-GROUP1 = 'BL1' AND SCREEN-GROUP3 <> 'OPU' AND SCREEN-GROUP3 <> 'TXT'.
IF R1 = 'X' .
SCREEN-INPUT = '1' .
ELSE.
SCREEN-INPUT = '0' .
ENDIF.
ELSEIF SCREEN-GROUP1 = 'BL2' AND SCREEN-GROUP3 <> 'OPU' AND SCREEN-GROUP3 <> 'TXT'.
IF R2 = 'X' .
SCREEN-INPUT = '1' .
ELSE.
SCREEN-INPUT = '0' .
ENDIF.
ELSEIF SCREEN-GROUP1 = 'BL3' AND SCREEN-GROUP3 <> 'OPU' AND SCREEN-GROUP3 <> 'TXT'.
IF R3 = 'X' .
SCREEN-INPUT = '1' .
ELSE.
SCREEN-INPUT = '0' .
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
**Check & Get Controlling Area
SELECT SINGLE KOKRS FROM TKA02 INTO T_KOKRS
WHERE BUKRS = P_BUKRS.
IF SY-SUBRC <> 0.
MESSAGE E002(/TDK/CB00020).
ENDIF.
PERFORM PROCESS_DATA.
**CREATE BDC FOR CONTROLLING AREA
PERFORM BDC_DATA.
IF C4 = 'X'.
PERFORM OUTPUT_DATA_B.
ELSE.
PERFORM OUTPUT_DATA_F.
ENDIF.
*&---------------------------------------------------------------------*
*& Form PUSHBOTTONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM PUSHBOTTONS .
CASE SSCRFIELDS-UCOMM.
WHEN 'LIST'.
IF LIST IS INITIAL.
MESSAGE E244(KD).
ENDIF.
CALL FUNCTION 'K_SETTLEMENT_LISTVARIANTS_GET'
EXPORTING
INCL_VARIANT_WIP = 'X'
ID_VARIANT_COS = VAR_COS
ID_VARIANT_WIP = VAR_WIP
IMPORTING
ED_VARIANT_COS = VAR_COS
ED_VARIANT_WIP = VAR_WIP.
IF NOT VAR_COS IS INITIAL OR NOT VAR_WIP IS INITIAL.
GB_LIST_CHANGED = 'X'.
ENDIF.
WHEN 'TECH'.
* IF SY-REPID <> 'RKO7CO88' AND SY-REPID <> 'RKO7KO8G'.
* GB_AUFGR = SPACE.
* ELSE.
GB_AUFGR = 'X'.
* ENDIF.
CALL FUNCTION 'K_SETTLEMENT_TECHINFO_GET'
EXPORTING
INCL_AUFGR = GB_AUFGR
INCL_COUNT_COM = 'X'
INCL_TRACE_OBJNR = 'X'
ID_AUFGR = ERRGR
ID_COUNT_COM = COUNT
ID_TRACE_OBJNR = IT_TRACE-OBJNR
ID_RFC_NO = RFC_NO
IMPORTING
ED_AUFGR = ERRGR
ED_COUNT_COM = COUNT
ED_TRACE_OBJNR = IT_TRACE-OBJNR
ED_RFC_NO = RFC_NO.
IF COUNT IS INITIAL.
COUNT = '10'.
ENDIF.
IF NOT ERRGR IS INITIAL OR NOT IT_TRACE-OBJNR IS INITIAL
OR COUNT <> 10.
GB_TECH_CHANGED = 'X'.
ENDIF.
IF NOT RFC_NO IS INITIAL.
* gb_tech_changed = 'X'.
ENDIF.
REFRESH IT_TRACE.
IF NOT IT_TRACE-OBJNR IS INITIAL.
APPEND IT_TRACE.
ENDIF.
ENDCASE.
ENDFORM. " PUSHBOTTONS
*&---------------------------------------------------------------------*
*& Form CHANGE_ICONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM CHANGE_ICONS .
IF LD_RFCGR IS INITIAL.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
NAME = 'ICON_ENTER_MORE'
INFO = SD_TEXT_NGW
IMPORTING
RESULT = PU_LIST.
ELSE.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
NAME = 'ICON_DISPLAY_MORE'
INFO = SD_TEXT_NGW
IMPORTING
RESULT = PU_LIST.
ENDIF.
* clear icons if box was cleared
IF LIST IS INITIAL AND GB_LIST_CHANGED = 'X'.
CLEAR: GB_LIST_CHANGED, VAR_COS, VAR_WIP.
ENDIF.
* clear icons if box was cleared
IF LIST IS INITIAL AND GB_LIST_CHANGED = 'X'.
CLEAR: GB_LIST_CHANGED, VAR_COS, VAR_WIP.
ENDIF.
* set correct icons on pushbuttons
IF GB_LIST_CHANGED = 'X'.
WRITE: ICON_DISPLAY_MORE TO PU_LIST AS ICON.
WRITE: TEXT-PU1 TO PU_LIST+4.
ELSE.
WRITE: ICON_ENTER_MORE TO PU_LIST AS ICON.
WRITE: TEXT-PU1 TO PU_LIST+4.
ENDIF.
IF GB_TECH_CHANGED = 'X'.
WRITE: ICON_DISPLAY_MORE TO PU_TECH AS ICON.
WRITE: TEXT-PU2 TO PU_TECH+4.
ELSE.
WRITE: ICON_ENTER_MORE TO PU_TECH AS ICON.
WRITE: TEXT-PU2 TO PU_TECH+4.
ENDIF.
ENDFORM. " CHANGE_ICONS
*&---------------------------------------------------------------------*
*& Form CHECK_VALUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM CHECK_VALUE .
**Company Code / Plant Existency Check
IF P_WERKS IS NOT INITIAL.
SELECT SINGLE BUKRS BWKEY FROM T001K
INTO (T_BUKRS ,T_BWKEY)
WHERE BUKRS = P_BUKRS
AND BWKEY = P_WERKS-LOW.
IF SY-SUBRC <> 0.
MESSAGE E001(/TDK/CB00020) .
ENDIF.
ELSE.
SELECT SINGLE BUKRS FROM T001K
INTO T_BUKRS
WHERE BUKRS = P_BUKRS.
IF SY-SUBRC <> 0.
MESSAGE E001(/TDK/CB00020) .
ENDIF.
ENDIF.
*Controll Regulation for Data Selection
IF P_GROUP <> ''.
IF ( P_BU <> '' OR P_SBU <> '' OR P_CBU <> '' OR P_PRCTR <> '').
P_BU = ''.
P_CBU = ''.
P_SBU = ''.
P_PRCTR = ''.
MESSAGE E003(/TDK/CB00020) WITH P_GROUP .
ENDIF.
ELSEIF P_PRCTR <>''.
IF ( P_BU <> '' OR P_CBU <> '' OR P_SBU <> '').
P_BU = ''.
P_CBU = ''.
P_SBU = ''.
MESSAGE E003(/TDK/CB00020) WITH P_PRCTR .
ENDIF.
ELSEIF P_SBU <> ''.
IF ( P_BU <> '' OR P_CBU <> '' ).
P_BU = ''.
P_CBU = ''.
MESSAGE E003(/TDK/CB00020) WITH P_SBU .
ENDIF.
ELSEIF P_CBU <> ''.
IF P_BU <> ''.
P_BU = ''.
MESSAGE E003(/TDK/CB00020) WITH P_CBU .
ENDIF.
ENDIF.
ENDFORM. " CHECK_VALUE
*&---------------------------------------------------------------------*
*& Form PRE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM PRE_DATA .
SELECT SINGLE KOKRS FROM TKA02 INTO T_KOKRS
WHERE BUKRS = P_BUKRS.
IF R1 = 'X'.
IF P_VERSA <> ''.
SELECT SINGLE * FROM TKKAP
WHERE KOKRS = T_KOKRS
AND VERSA = P_VERSA.
IF SY-SUBRC <> 0.
MESSAGE E004(/TDK/CB00020).
ENDIF.
ENDIF.
IF P_VAR <> ''.
SELECT SINGLE * FROM LTDX
WHERE RELID = 'LT'
AND REPORT = 'SAPKKA07'
AND ( USERNAME = '' OR USERNAME = SY-UNAME )
AND VARIANT = P_VAR.
IF SY-SUBRC <> 0.
MESSAGE E005(/TDK/CB00020).
ENDIF.
ENDIF.
ELSEIF R2 = 'X'.
IF P_AWVRS <> ''.
SELECT SINGLE * FROM TKV09
WHERE KOKRS = T_KOKRS
AND AWVRS = P_AWVRS.
IF SY-SUBRC <> 0.
MESSAGE E006(/TDK/CB00020).
ENDIF.
ENDIF.
ELSE.
IF LIST = 'X'.
IF VAR_COS <> ''.
SELECT SINGLE * FROM LTDX
WHERE RELID = 'LT'
AND REPORT = 'SAPLKALV'
AND HANDLE = 'COST'
AND ( USERNAME = '' OR USERNAME = SY-UNAME )
AND VARIANT = VAR_COS.
IF SY-SUBRC <> 0.
MESSAGE E005(/TDK/CB00020).
ENDIF.
ENDIF.
IF VAR_WIP <> ''.
SELECT SINGLE * FROM LTDX
WHERE RELID = 'LT'
AND REPORT = 'SAPLKALV'
AND HANDLE = 'WIP'
AND ( USERNAME = '' OR USERNAME = SY-UNAME )
AND VARIANT = VAR_WIP.
IF SY-SUBRC <> 0.
MESSAGE E005(/TDK/CB00020).
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " PRE_DATA
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM PROCESS_DATA .
**Get First day of fiscal year and period
CALL FUNCTION 'BAPI_COAREA_GETPERIODLIMITS'
EXPORTING
CONTROLLINGAREAID = T_KOKRS
FISCAL_PERIOD = P_MONAT
FISCAL_YEAR = P_GJAHR
IMPORTING
FIRST_DAY_OF_PERIOD = T_FIRST_DAY
LAST_DAY_OF_PERIOD = T_LAST_DAY
* LAST_NORMAL_PERIOD =
* RETURN =
.
IF SY-SUBRC <> 0.
MESSAGE E007(/TDK/CB00020).
ENDIF.
**Get Order List of Selected Plant
IF T_BWKEY <> '' AND P_PRCTR <> ''.
SELECT * FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE ORDER_TAB
WHERE AUTYP <> '01'
AND WERKS = T_BWKEY
AND LOEKZ = ''
AND PRCTR = P_PRCTR.
IF ORDER_TAB[] IS INITIAL.
MESSAGE E008(/TDK/CB00020).
ENDIF.
ELSEIF T_BWKEY = '' AND P_PRCTR <> '' .
SELECT * FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE ORDER_TAB
WHERE AUTYP <> '01'
AND LOEKZ = ''
AND PRCTR = P_PRCTR.
IF ORDER_TAB[] IS INITIAL.
MESSAGE E008(/TDK/CB00020).
ENDIF.
ELSEIF T_BWKEY = '' AND P_PRCTR = '' .
SELECT * FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE ORDER_TAB
WHERE AUTYP <> '01'
AND LOEKZ = ''.
IF ORDER_TAB[] IS INITIAL.
MESSAGE E008(/TDK/CB00020).
ENDIF.
ELSEIF T_BWKEY <> '' AND P_PRCTR = '' .
SELECT * FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE ORDER_TAB
WHERE AUTYP <> '01'
AND WERKS = T_BWKEY
AND LOEKZ = ''.
IF ORDER_TAB[] IS INITIAL.
MESSAGE E008(/TDK/CB00020).
ENDIF.
ENDIF.
LOOP AT ORDER_TAB.
SELECT * FROM AFKO
APPENDING CORRESPONDING FIELDS OF TABLE ORDER_HEAD
WHERE AUFNR = ORDER_TAB-AUFNR.
* AND APRIO IN P_APRIO.
ENDLOOP .
IF ORDER_HEAD[] IS INITIAL.
MESSAGE E009(/TDK/CB00020).
ENDIF.
* MESSAGE E010(/TDK/CB00020) WITH ORDER_TAB-AUFNR P_APRIO.
* ELSE.
* IF AFKO-APRIO = P_APRIO-LOW.
LOOP AT ORDER_TAB.
READ TABLE ORDER_HEAD WITH KEY AUFNR = ORDER_TAB-AUFNR.
IF SY-SUBRC = 0.
IF ORDER_HEAD-APRIO IN P_APRIO.
ORDER_TAB-APRIO = ORDER_HEAD-APRIO.
SELECT SINGLE * FROM AFPO
WHERE AUFNR = ORDER_TAB-AUFNR.
IF SY-SUBRC <> 0.
MESSAGE E011(/TDK/CB00020).
ELSE.
ORDER_TAB-MATNR = AFPO-MATNR.
ENDIF.
MODIFY ORDER_TAB.
ELSE.
DELETE ORDER_TAB.
MESSAGE S010(/TDK/CB00020) WITH ORDER_TAB-AUFNR P_APRIO-LOW.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR ORDER_TAB .
SORT ORDER_TAB BY MATNR.
LOOP AT ORDER_TAB.
WA_MATNR-MATNR = ORDER_TAB-MATNR.
APPEND WA_MATNR TO T_MATNR.
CLEAR WA_MATNR.
ENDLOOP.
CLEAR ORDER_TAB .
SORT T_MATNR BY MATNR ASCENDING.
DELETE ADJACENT DUPLICATES FROM T_MATNR COMPARING MATNR.
*Get Material Organization
CALL FUNCTION '/TDK/C_MAT_ORG'
EXPORTING
I_PATTERN = '1'
I_BUKRS = P_BUKRS
IT_MATNR = T_MATNR
I_DATE = T_LAST_DAY
I_SETNAME = '0000T_T'
* I_BU =
IMPORTING
ET_MAT_HIER = T_MAT_HIER
EXCEPTIONS
INVALID_MATERIAL = 1
INVALID_ITEM_GROUP = 2
INVALID_SETNAME = 3
INVALID_BU = 4
INVALID_SEGMENT = 5
INVALID_PARAMETER = 6
INVALID_COMPANY = 7
OTHERS = 8
.
IF SY-SUBRC <> 0.
MESSAGE E012(/TDK/CB00020).
ENDIF.
LOOP AT T_MAT_HIER INTO TH_MAT_HIER.
*Data Limitation(Material / Organization)
IF P_GROUP <> ''.
IF TH_MAT_HIER-/EPCOS/TDKKL = P_GROUP.
MOVE-CORRESPONDING TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ELSE.
DELETE ORDER_TAB WHERE MATNR = TH_MAT_HIER-MATNR.
ENDIF.
ELSEIF P_BU <> ''.
IF TH_MAT_HIER-ORG_LV3 = P_BU.
MOVE-CORRESPONDING TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ELSE.
DELETE ORDER_TAB WHERE MATNR = TH_MAT_HIER-MATNR.
ENDIF.
ELSEIF P_CBU <> ''.
IF TH_MAT_HIER-ORG_LV4 = P_CBU.
MOVE-CORRESPONDING TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ELSE.
DELETE ORDER_TAB WHERE MATNR = TH_MAT_HIER-MATNR.
ENDIF.
ELSEIF P_SBU <> '' .
IF TH_MAT_HIER-SEGMENT = P_SBU .
MOVE-CORRESPONDING TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ELSE.
DELETE ORDER_TAB WHERE MATNR = TH_MAT_HIER-MATNR.
ENDIF.
ELSE.
MOVE TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ENDIF.
ENDLOOP.
IF WA_MAT_HIER[] IS INITIAL.
MESSAGE E013(/TDK/CB00020).
ENDIF.
LOOP AT ORDER_TAB.
LOOP AT WA_MAT_HIER WHERE MATNR = ORDER_TAB-MATNR.
MOVE-CORRESPONDING ORDER_TAB TO ITAB.
ITAB-ORG_LV3 = WA_MAT_HIER-ORG_LV3.
ITAB-ORG_LV4 = WA_MAT_HIER-ORG_LV4.
ITAB-SEGMENT = WA_MAT_HIER-SEGMENT.
ITAB-/EPCOS/TDKKL = WA_MAT_HIER-/EPCOS/TDKKL.
APPEND ITAB.
ENDLOOP.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form OUTPUT_DATA_B
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM OUTPUT_DATA_B.
LOOP AT ITAB.
IF ITAB-AUFNR IS NOT INITIAL.
S_AUFNR-SIGN = 'I'.
S_AUFNR-OPTION = 'EQ'.
S_AUFNR-LOW = ITAB-AUFNR.
APPEND S_AUFNR.
ENDIF.
IF ITAB-WERKS IS NOT INITIAL.
S_WERKS-SIGN = 'I'.
S_WERKS-OPTION = 'EQ'.
S_WERKS-LOW = ITAB-WERKS.
APPEND S_WERKS.
ENDIF.
DELETE ADJACENT DUPLICATES FROM S_WERKS.
ENDLOOP.
* Job open
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
JOBNAME = JOBNAME
SDLSTRTDT = SY-DATUM
SDLSTRTTM = SY-UZEIT
IMPORTING
JOBCOUNT = JOBCOUNT
EXCEPTIONS
CANT_CREATE_JOB = 01
INVALID_JOB_DATA = 02
JOBNAME_MISSING = 03.
IF SY-SUBRC NE 0.
"error processing
ENDIF.
IF R1 = 'X'.
IF R1_2 = 'X' AND P_VERSA <> ''.
SUBMIT SAPKKA07 USING SELECTION-SCREEN '1000' AND RETURN
WITH ABGRWERK IN S_WERKS
WITH INCFAUFT = C1
WITH INCPKOSA = C2
WITH INCPIAUF = C3
WITH ABGRAUFN IN S_AUFNR
WITH ABGRMONA = P_MONAT
WITH ABGRJAHR = P_GJAHR
WITH ABGRVERS-LOW = P_VERSA
WITH WITHIMSG = R1_C
WITH OBJ_LST = R1_C1
WITH FEHLAUFT = R1_C2
WITH NO_0_WIP = R1_C3
WITH P_CCCURR = 'X'
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ELSEIF R1_1 = 'X'.
SUBMIT SAPKKA07 USING SELECTION-SCREEN '1000' AND RETURN
WITH ABGRWERK IN S_WERKS
WITH INCFAUFT = C1
WITH INCPKOSA = C2
WITH INCPIAUF = C3
WITH ABGRAUFN IN S_AUFNR
WITH ABGRMONA = P_MONAT
WITH ABGRJAHR = P_GJAHR
WITH WITHIMSG = R1_C
WITH OBJ_LST = R1_C1
WITH FEHLAUFT = R1_C2
WITH NO_0_WIP = R1_C3
WITH P_CCCURR = 'X'
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ENDIF.
ELSEIF R2 = 'X'.
IF R2_2 = 'X' AND P_AWVRS <> ''.
SUBMIT RKKKS1N0 USING SELECTION-SCREEN '1000' AND RETURN
WITH WERKS IN S_WERKS
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH AUFNR IN S_AUFNR
WITH PA_POPER = P_MONAT
WITH PA_GJAHR = P_GJAHR
WITH PA_AWVSE = P_AWVRS
WITH RFCPROC = R2_C1
WITH PA_LISTF = R2_C2
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ELSEIF R2_1 = 'X'.
SUBMIT RKKKS1N0 USING SELECTION-SCREEN '1000' AND RETURN
WITH WERKS IN S_WERKS
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH AUFNR IN S_AUFNR
WITH PA_POPER = P_MONAT
WITH PA_GJAHR = P_GJAHR
WITH RFCPROC = R2_C1
WITH PA_LISTF = R2_C2
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ENDIF.
ELSEIF R3 = 'X'.
IF P_PERIO <> ''.
SUBMIT RKO7CO88 USING SELECTION-SCREEN '1000' AND RETURN
WITH WERKS IN S_WERKS
WITH AUFNR IN S_AUFNR
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH PERIO = P_MONAT
WITH GJAHR = P_GJAHR
WITH VAART = P_VAART
WITH BUPERIO = P_PERIO
WITH AUSF = R3_1
WITH STOR = R3_2
WITH TESTLAUF = R3_C1
WITH RFCPROC = R3_C2
WITH TDCHECK = R3_C3
WITH LIST = LIST
WITH VAR_COS = VAR_COS
WITH VAR_WIP = VAR_WIP
WITH ERRGR = ERRGR
WITH COUNT = COUNT
WITH OBJNR = IT_TRACE-OBJNR
WITH RFC_NO = RFC_NO
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ELSE.
SUBMIT RKO7CO88 USING SELECTION-SCREEN '1000' AND RETURN
WITH WERKS IN S_WERKS
WITH AUFNR IN S_AUFNR
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH PERIO = P_MONAT
WITH GJAHR = P_GJAHR
WITH VAART = P_VAART
WITH AUSF = R3_1
WITH STOR = R3_2
WITH TESTLAUF = R3_C1
WITH RFCPROC = R3_C2
WITH TDCHECK = R3_C3
WITH LIST = LIST
WITH VAR_COS = VAR_COS
WITH VAR_WIP = VAR_WIP
WITH ERRGR = ERRGR
WITH COUNT = COUNT
WITH OBJNR = IT_TRACE-OBJNR
WITH RFC_NO = RFC_NO
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ENDIF.
ENDIF.
* Close job
STARTTIME-SDLSTRTDT = SY-DATUM + 1.
STARTTIME-SDLSTRTTM = '220000'.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
" event_id = starttime-eventid
" event_param = starttime-eventparm
" event_periodic = starttime-periodic
JOBCOUNT = JOBCOUNT
JOBNAME = JOBNAME
" laststrtdt = starttime-laststrtdt
" laststrttm = starttime-laststrttm
" prddays = 1
" prdhours = 0
" prdmins = 0
" prdmonths = 0
" prdweeks = 0
" sdlstrtdt = starttime-sdlstrtdt
" sdlstrttm = starttime-sdlstrttm
STRTIMMED = STARTTIMEIMMEDIATE
" targetsystem = host
EXCEPTIONS
CANT_START_IMMEDIATE = 01
INVALID_STARTDATE = 02
JOBNAME_MISSING = 03
JOB_CLOSE_FAILED = 04
JOB_NOSTEPS = 05
JOB_NOTEX = 06
LOCK_FAILED = 07
OTHERS = 99.
IF SY-SUBRC EQ 0.
"error processing
ENDIF.
ENDFORM. " OUTPUT_DATA_B
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2155 text
* -->P_2156 text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR T_BDC.
T_BDC-PROGRAM = PROGRAM.
T_BDC-DYNPRO = DYNPRO.
T_BDC-DYNBEGIN = 'X'.
APPEND T_BDC.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2160 text
* -->P_2161 text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR T_BDC.
T_BDC-FNAM = FNAM.
T_BDC-FVAL = FVAL.
APPEND T_BDC.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form OUTPUT_DATA_F
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM OUTPUT_DATA_F .
LOOP AT ITAB.
IF ITAB-AUFNR IS NOT INITIAL.
S_AUFNR-SIGN = 'I'.
S_AUFNR-OPTION = 'EQ'.
S_AUFNR-LOW = ITAB-AUFNR.
APPEND S_AUFNR.
ENDIF.
IF ITAB-WERKS IS NOT INITIAL.
S_WERKS-SIGN = 'I'.
S_WERKS-OPTION = 'EQ'.
S_WERKS-LOW = ITAB-WERKS.
APPEND S_WERKS.
ENDIF.
DELETE ADJACENT DUPLICATES FROM S_WERKS.
ENDLOOP.
IF R1 = 'X'.
IF R1_2 = 'X' AND P_VERSA <> ''.
SUBMIT SAPKKA07 USING SELECTION-SCREEN '1000'
WITH ABGRWERK IN S_WERKS
WITH INCFAUFT = C1
WITH INCPKOSA = C2
WITH INCPIAUF = C3
WITH ABGRAUFN IN S_AUFNR
WITH ABGRMONA = P_MONAT
WITH ABGRJAHR = P_GJAHR
WITH ABGRVERS-LOW = P_VERSA
WITH WITHIMSG = R1_C
WITH OBJ_LST = R1_C1
WITH FEHLAUFT = R1_C2
WITH NO_0_WIP = R1_C3
WITH P_CCCURR = 'X' AND RETURN.
ELSEIF R1_1 = 'X'.
SUBMIT SAPKKA07 USING SELECTION-SCREEN '1000'
WITH ABGRWERK IN S_WERKS
WITH INCFAUFT = C1
WITH INCPKOSA = C2
WITH INCPIAUF = C3
WITH ABGRAUFN IN S_AUFNR
WITH ABGRMONA = P_MONAT
WITH ABGRJAHR = P_GJAHR
WITH WITHIMSG = R1_C
WITH OBJ_LST = R1_C1
WITH FEHLAUFT = R1_C2
WITH NO_0_WIP = R1_C3
WITH P_CCCURR = 'X' AND RETURN.
ENDIF.
ELSEIF R2 = 'X'.
IF R2_2 = 'X' AND P_AWVRS <> ''.
SUBMIT RKKKS1N0 USING SELECTION-SCREEN '1000'
WITH WERKS IN S_WERKS
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH AUFNR IN S_AUFNR
WITH PA_POPER = P_MONAT
WITH PA_GJAHR = P_GJAHR
WITH PA_AWVSE = P_AWVRS
WITH RFCPROC = R2_C1
WITH PA_LISTF = R2_C2 AND RETURN.
ELSEIF R2_1 = 'X'.
SUBMIT RKKKS1N0 USING SELECTION-SCREEN '1000'
WITH WERKS IN S_WERKS
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH AUFNR IN S_AUFNR
WITH PA_POPER = P_MONAT
WITH PA_GJAHR = P_GJAHR
WITH RFCPROC = R2_C1
WITH PA_LISTF = R2_C2 AND RETURN.
ENDIF.
ELSEIF R3 = 'X'.
IF P_PERIO <> ''.
SUBMIT RKO7CO88 USING SELECTION-SCREEN '1000'
WITH WERKS IN S_WERKS
WITH AUFNR IN S_AUFNR
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH PERIO = P_MONAT
WITH GJAHR = P_GJAHR
WITH VAART = P_VAART
WITH BUPERIO = P_PERIO
WITH AUSF = R3_1
WITH STOR = R3_2
WITH TESTLAUF = R3_C1
WITH RFCPROC = R3_C2
WITH TDCHECK = R3_C3
WITH LIST = LIST
WITH VAR_COS = VAR_COS
WITH VAR_WIP = VAR_WIP
WITH ERRGR = ERRGR
WITH COUNT = COUNT
WITH OBJNR = IT_TRACE-OBJNR
WITH RFC_NO = RFC_NO AND RETURN.
ELSE.
SUBMIT RKO7CO88 USING SELECTION-SCREEN '1000'
WITH WERKS IN S_WERKS
WITH AUFNR IN S_AUFNR
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH PERIO = P_MONAT
WITH GJAHR = P_GJAHR
WITH VAART = P_VAART
WITH AUSF = R3_1
WITH STOR = R3_2
WITH TESTLAUF = R3_C1
WITH RFCPROC = R3_C2
WITH TDCHECK = R3_C3
WITH LIST = LIST
WITH VAR_COS = VAR_COS
WITH VAR_WIP = VAR_WIP
WITH ERRGR = ERRGR
WITH COUNT = COUNT
WITH OBJNR = IT_TRACE-OBJNR
WITH RFC_NO = RFC_NO AND RETURN.
ENDIF.
ENDIF.
ENDFORM. " OUTPUT_DATA_F
*&---------------------------------------------------------------------*
*& Form BDC_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM BDC_DATA .
DATA: L_MODE TYPE C.
MOVE 'N' TO L_MODE.
*CREATE BDC FOR CHANGE CONTROLLING AREA IN SCREEN
REFRESH T_BDC.
CLEAR T_BDC.
* PERFORM BDC_DYNPRO USING 'SAPKKA07' '1000'.
* PERFORM BDC_FIELD USING 'BDC_CURSOR'
* 'ABGRAUFA-LOW'.
* PERFORM BDC_FIELD USING 'BDC_OKCODE'
* '=OKKS'.
* PERFORM BDC_FIELD USING 'ABGRMONA'
* P_MONAT.
* PERFORM BDC_FIELD USING 'ABGRJAHR'
* P_GJAHR.
* PERFORM BDC_DYNPRO USING 'SAPLSPO4' '0300'.
* PERFORM BDC_FIELD USING 'BDC_CURSOR'
* 'SVALD-VALUE(01)'.
* PERFORM BDC_FIELD USING 'BDC_OKCODE'
* '=COD1'.
* PERFORM BDC_FIELD USING 'SVALD-VALUE(01)'
* T_KOKRS.
* PERFORM BDC_DYNPRO USING 'SAPKKA07' '1000'.
* PERFORM BDC_FIELD USING 'BDC_OKCODE'
* '/EENDE'.
* PERFORM BDC_FIELD USING 'BDC_CURSOR'
* 'ABGRJAHR'.
*
* CALL TRANSACTION '/TDK/CT0210'
* USING T_BDC
* MODE L_MODE
* UPDATE 'S'
* MESSAGES INTO T_MSG.
PERFORM BDC_DYNPRO USING 'SAPLKO71' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/ESKRS'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LKO74-GJAHR'.
PERFORM BDC_DYNPRO USING 'SAPLSPO4' '0300'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'SVALD-VALUE(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=COD1'.
PERFORM BDC_FIELD USING 'SVALD-VALUE(01)'
T_KOKRS.
PERFORM BDC_DYNPRO USING 'SAPLKO71' '1000'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LKO74-GJAHR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'LKO74-PERIO'
P_MONAT.
PERFORM BDC_FIELD USING 'LKO74-GJAHR'
P_GJAHR.
PERFORM BDC_DYNPRO USING 'SAPLKO71' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/EERET'.
CALL TRANSACTION 'CO88'
USING T_BDC
MODE L_MODE
UPDATE 'S'
MESSAGES INTO T_MSG.
ENDFORM. " BDC_DATA
*& TABLES
*&---------------------------------------------------------------------*
TABLES:T001,
TKA02,
TKKAP,
LTDX,
TKV09,
AUFK,
AFKO,
AFPO,
SSCRFIELDS,
T001K.
*&---------------------------------------------------------------------*
*& G L O B L E V A R I A B L E
*&---------------------------------------------------------------------*
TYPE-POOLS ICON.
*DATA FUNCTXT TYPE SMP_DYNTXT.
DATA: TXTW(45) TYPE C.
DATA:LD_RFCGR TYPE SPTA_RFCGR,
SD_TEXT_NGW(30) TYPE C.
DATA: RFCGR_DISPLAYFORMAT TYPE N VALUE '0'.
DATA:T_BUKRS TYPE BUKRS,
T_BWKEY TYPE BWKEY,
T_KOKRS TYPE KOKRS,
T_FIRST_DAY LIKE AFRU-BUDAT,
T_LAST_DAY LIKE AFRU-BUDAT.
DATA: T_BDC LIKE TABLE OF BDCDATA WITH HEADER LINE.
DATA: T_MSG TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE.
DATA: JOBNAME LIKE TBTCJOB-JOBNAME VALUE
'TRANSFER DATA'.
DATA: JOBCOUNT LIKE TBTCJOB-JOBCOUNT,
HOST LIKE MSXXLIST-HOST.
DATA: BEGIN OF STARTTIME.
INCLUDE STRUCTURE TBTCSTRT.
DATA: END OF STARTTIME.
DATA: STARTTIMEIMMEDIATE LIKE BTCH0000-CHAR1 VALUE 'X'.
*----------------------------------------------------------------------*
* INTERNAL TABLE
*----------------------------------------------------------------------*
DATA: IT_TRACE LIKE JSTO_PRE OCCURS 0 WITH HEADER LINE.
DATA:BEGIN OF ORDER_TAB OCCURS 0,
AUFNR LIKE AUFK-AUFNR,
WERKS LIKE AUFK-WERKS,
APRIO LIKE AFKO-APRIO,
MATNR LIKE AFPO-MATNR,
END OF ORDER_TAB.
DATA:BEGIN OF ORDER_HEAD OCCURS 0,
AUFNR LIKE AFKO-AUFNR,
APRIO LIKE AFKO-APRIO,
END OF ORDER_HEAD.
*DATA: BEGIN OF WA_MAT_HIER OCCURS 0,
* MATNR TYPE MATNR,
* /EPCOS/TDKKL TYPE /EPCOS/TDK_GRP,
* SEGMENT TYPE FB_SEGMENT,
* ORG_LV3 TYPE SETID,
* ORG_LV4 TYPE SETID,
* END OF WA_MAT_HIER.
DATA: BEGIN OF WA_MAT_HIER OCCURS 0.
INCLUDE STRUCTURE /TDK/SC0002.
DATA: END OF WA_MAT_HIER.
DATA: T_MATNR LIKE STANDARD TABLE OF /TDK/SC0001, "input parameter
WA_MATNR LIKE LINE OF T_MATNR.
DATA: T_MAT_HIER TYPE STANDARD TABLE OF /TDK/SC0002, "hierarchy
TH_MAT_HIER TYPE /TDK/SC0002. "header of hierarchy
DATA:BEGIN OF ITAB OCCURS 0,
ORG_LV3 TYPE SETID,
ORG_LV4 TYPE SETID,
SEGMENT TYPE FB_SEGMENT,
/EPCOS/TDKKL TYPE /EPCOS/TDK_GRP,
AUFNR LIKE AUFK-AUFNR,
WERKS LIKE AUFK-WERKS,
APRIO LIKE AFKO-APRIO,
MATNR LIKE AFPO-MATNR,
END OF ITAB.
RANGES:S_AUFNR FOR ITAB-AUFNR.
RANGES:S_WERKS FOR ITAB-WERKS.
*&---------------------------------------------------------------------*
*& SELECT-SCREEN
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B0 WITH FRAME TITLE TEXT-000.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS:P_BUKRS LIKE T001-BUKRS OBLIGATORY.
SELECT-OPTIONS: P_WERKS FOR T001K-BWKEY NO INTERVALS.
PARAMETERS:P_BU(34) TYPE C,
P_CBU(34) TYPE C,
P_SBU TYPE FB_SEGMENT,
P_PRCTR LIKE AUFK-PRCTR,
P_GROUP TYPE /EPCOS/TDK_GRP.
SELECTION-SCREEN :SKIP.
PARAMETERS:P_GJAHR TYPE GJAHR OBLIGATORY,
P_MONAT TYPE MONAT OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS: C1 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X',
C2 AS CHECKBOX USER-COMMAND CHECK ,
C3 AS CHECKBOX USER-COMMAND CHECK .
SELECTION-SCREEN :SKIP.
SELECT-OPTIONS: P_APRIO FOR AFKO-APRIO NO INTERVALS.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
PARAMETERS: R1 TYPE C RADIOBUTTON GROUP RGR1 DEFAULT 'X'
USER-COMMAND RAD_CLICK ,
R2 TYPE C RADIOBUTTON GROUP RGR1,
R3 TYPE C RADIOBUTTON GROUP RGR1.
SELECTION-SCREEN END OF BLOCK B3.
PARAMETERS: C4 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK B0.
SELECTION-SCREEN :SKIP.
**Work in Process: List
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 1(50) BUT1 USER-COMMAND BUTTON1 VISIBLE LENGTH 2.
SELECTION-SCREEN COMMENT 6(50) COM1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-007 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_1 RADIOBUTTON GROUP RGR3 MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(30) TEXT-010 FOR FIELD R1_1 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_2 RADIOBUTTON GROUP RGR3 MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(10) TEXT-011 FOR FIELD R1_2 MODIF ID BL1.
PARAMETERS:P_VERSA LIKE TKKAP-VERSA MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-008 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_C AS CHECKBOX USER-COMMAND CHECK MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(30) TEXT-012 FOR FIELD R1_C MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-009 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_C1 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X' MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(30) TEXT-013 FOR FIELD R1_C1 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_C2 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL1 .
SELECTION-SCREEN COMMENT 6(30) TEXT-014 FOR FIELD R1_C2 MODIF ID BL1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL1.
PARAMETERS: R1_C3 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL1.
SELECTION-SCREEN COMMENT 6(30) TEXT-015 FOR FIELD R1_C3 MODIF ID BL1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN :SKIP.
PARAMETERS:P_VAR LIKE LTDX-VARIANT MODIF ID BL1.
SELECTION-SCREEN END OF BLOCK B4.
SELECTION-SCREEN :SKIP.
**Variances: Manufacturing Orders and Product Cost Collectors
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 1(50) BUT2 USER-COMMAND BUTTON2 VISIBLE LENGTH 2.
SELECTION-SCREEN COMMENT 6(60) COM2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-005.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-007 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL2.
PARAMETERS: R2_1 RADIOBUTTON GROUP RGR4 MODIF ID BL2.
SELECTION-SCREEN COMMENT 6(30) TEXT-016 FOR FIELD R2_1 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL2.
PARAMETERS: R2_2 RADIOBUTTON GROUP RGR4 MODIF ID BL2.
SELECTION-SCREEN COMMENT 6(20) TEXT-017 FOR FIELD R2_2 MODIF ID BL2.
PARAMETERS:P_AWVRS LIKE TKV09-AWVRS MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-008 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL2.
PARAMETERS: R2_C1 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL2.
SELECTION-SCREEN COMMENT 6(30) TEXT-018 FOR FIELD R2_C1 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL2.
PARAMETERS: R2_C2 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X' MODIF ID BL2.
SELECTION-SCREEN COMMENT 6(30) TEXT-019 FOR FIELD R2_C2 MODIF ID BL2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B5.
SELECTION-SCREEN :SKIP.
**Settlement: Production Orders and Product Cost Collectors
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 1(50) BUT3 USER-COMMAND BUTTON3 VISIBLE LENGTH 2.
SELECTION-SCREEN COMMENT 6(60) COM3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK B6 WITH FRAME TITLE TEXT-006.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-007 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
PARAMETERS: P_VAART TYPE CO_VAART DEFAULT '1' MODIF ID BL3,
P_PERIO TYPE COBU_PERIO MODIF ID BL3.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-022 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_1 RADIOBUTTON GROUP RGR5 MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(30) TEXT-023 FOR FIELD R3_1 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_2 RADIOBUTTON GROUP RGR5 MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(20) TEXT-024 FOR FIELD R3_2 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-008 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_C1 AS CHECKBOX USER-COMMAND CHECK DEFAULT 'X' MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(30) TEXT-025 FOR FIELD R3_C1 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_C2 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(30) TEXT-026 FOR FIELD R3_C2 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: R3_C3 AS CHECKBOX USER-COMMAND CHECK MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(30) TEXT-027 FOR FIELD R3_C3 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN :SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) TEXT-009 MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(1) TEXT-000 MODIF ID BL3.
PARAMETERS: LIST LIKE LKO74-LIST MODIF ID BL3.
SELECTION-SCREEN COMMENT 6(10) TEXT-028 FOR FIELD LIST MODIF ID BL3.
SELECTION-SCREEN PUSHBUTTON 33(30) PU_LIST USER-COMMAND LIST MODIF ID BL3.
SELECTION-SCREEN END OF LINE.
* technical fields -> no output because on pushbuttons
SELECTION-SCREEN BEGIN OF BLOCK FELDER WITH FRAME .
PARAMETERS: COUNT LIKE LKO74-COUNT_COM DEFAULT '10' NO-DISPLAY MODIF ID BL3.
PARAMETERS: ERRGR LIKE LKO74-AUFGR NO-DISPLAY MODIF ID BL3.
PARAMETERS: RFC_NO LIKE LKO74-RFC_NO NO-DISPLAY MODIF ID BL3.
PARAMETERS: VAR_COS LIKE LKO74-VARIANT_COS NO-DISPLAY MODIF ID BL3,
VAR_WIP LIKE LKO74-VARIANT_WIP NO-DISPLAY MODIF ID BL3.
SELECTION-SCREEN END OF BLOCK FELDER.
SELECTION-SCREEN :SKIP.
SELECTION-SCREEN :SKIP.
* Pushbutton for technical settings
SELECTION-SCREEN PUSHBUTTON 1(30) PU_TECH USER-COMMAND TECH MODIF ID BL3.
SELECTION-SCREEN END OF BLOCK B6.
*&---------------------------------------------------------------------*
*& INITIALIZATION
*&---------------------------------------------------------------------*
INCLUDE RKO74TOP.
INITIALIZATION.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT1 .
COM1 = 'Work in Process: List'.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT2 .
COM2 = 'Variances: Manufacturing Orders and Product Cost Collectors'.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT3 .
COM3 = 'Settlement: Production Orders and Product Cost Collectors'.
PERFORM CHANGE_ICONS.
AT SELECTION-SCREEN.
CASE SY-UCOMM.
WHEN 'BUTTON1'.
IF BUT1 = '@K1@'.
WRITE ICON_DATA_AREA_COLLAPSE AS ICON TO BUT1.
COM1 = 'Work in Process: List'.
ELSE.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT1.
COM1 = 'Work in Process: List'.
ENDIF.
WHEN 'BUTTON2'.
IF BUT2 = '@K1@'.
WRITE ICON_DATA_AREA_COLLAPSE AS ICON TO BUT2.
COM2 = 'Variances: Manufacturing Orders and Product Cost Collectors'.
ELSE.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT2.
COM2 = 'Variances: Manufacturing Orders and Product Cost Collectors'.
ENDIF.
WHEN 'BUTTON3'.
IF BUT3 = '@K1@'.
WRITE ICON_DATA_AREA_COLLAPSE AS ICON TO BUT3.
COM3 = 'Settlement: Production Orders and Product Cost Collectors'.
ELSE.
WRITE ICON_DATA_AREA_EXPAND AS ICON TO BUT3.
COM3 = 'Settlement: Production Orders and Product Cost Collectors'.
ENDIF.
ENDCASE.
PERFORM PUSHBOTTONS.
PERFORM CHANGE_ICONS.
PERFORM CHECK_VALUE.
PERFORM PRE_DATA .
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF BUT1 = '@K2@' AND SCREEN-GROUP1 = 'BL1'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
IF BUT2 = '@K2@' AND SCREEN-GROUP1 = 'BL2'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
IF BUT3 = '@K2@' AND SCREEN-GROUP1 = 'BL3'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
LOOP AT SCREEN .
IF SCREEN-GROUP1 = 'BL1' AND SCREEN-GROUP3 <> 'OPU' AND SCREEN-GROUP3 <> 'TXT'.
IF R1 = 'X' .
SCREEN-INPUT = '1' .
ELSE.
SCREEN-INPUT = '0' .
ENDIF.
ELSEIF SCREEN-GROUP1 = 'BL2' AND SCREEN-GROUP3 <> 'OPU' AND SCREEN-GROUP3 <> 'TXT'.
IF R2 = 'X' .
SCREEN-INPUT = '1' .
ELSE.
SCREEN-INPUT = '0' .
ENDIF.
ELSEIF SCREEN-GROUP1 = 'BL3' AND SCREEN-GROUP3 <> 'OPU' AND SCREEN-GROUP3 <> 'TXT'.
IF R3 = 'X' .
SCREEN-INPUT = '1' .
ELSE.
SCREEN-INPUT = '0' .
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
**Check & Get Controlling Area
SELECT SINGLE KOKRS FROM TKA02 INTO T_KOKRS
WHERE BUKRS = P_BUKRS.
IF SY-SUBRC <> 0.
MESSAGE E002(/TDK/CB00020).
ENDIF.
PERFORM PROCESS_DATA.
**CREATE BDC FOR CONTROLLING AREA
PERFORM BDC_DATA.
IF C4 = 'X'.
PERFORM OUTPUT_DATA_B.
ELSE.
PERFORM OUTPUT_DATA_F.
ENDIF.
*&---------------------------------------------------------------------*
*& Form PUSHBOTTONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM PUSHBOTTONS .
CASE SSCRFIELDS-UCOMM.
WHEN 'LIST'.
IF LIST IS INITIAL.
MESSAGE E244(KD).
ENDIF.
CALL FUNCTION 'K_SETTLEMENT_LISTVARIANTS_GET'
EXPORTING
INCL_VARIANT_WIP = 'X'
ID_VARIANT_COS = VAR_COS
ID_VARIANT_WIP = VAR_WIP
IMPORTING
ED_VARIANT_COS = VAR_COS
ED_VARIANT_WIP = VAR_WIP.
IF NOT VAR_COS IS INITIAL OR NOT VAR_WIP IS INITIAL.
GB_LIST_CHANGED = 'X'.
ENDIF.
WHEN 'TECH'.
* IF SY-REPID <> 'RKO7CO88' AND SY-REPID <> 'RKO7KO8G'.
* GB_AUFGR = SPACE.
* ELSE.
GB_AUFGR = 'X'.
* ENDIF.
CALL FUNCTION 'K_SETTLEMENT_TECHINFO_GET'
EXPORTING
INCL_AUFGR = GB_AUFGR
INCL_COUNT_COM = 'X'
INCL_TRACE_OBJNR = 'X'
ID_AUFGR = ERRGR
ID_COUNT_COM = COUNT
ID_TRACE_OBJNR = IT_TRACE-OBJNR
ID_RFC_NO = RFC_NO
IMPORTING
ED_AUFGR = ERRGR
ED_COUNT_COM = COUNT
ED_TRACE_OBJNR = IT_TRACE-OBJNR
ED_RFC_NO = RFC_NO.
IF COUNT IS INITIAL.
COUNT = '10'.
ENDIF.
IF NOT ERRGR IS INITIAL OR NOT IT_TRACE-OBJNR IS INITIAL
OR COUNT <> 10.
GB_TECH_CHANGED = 'X'.
ENDIF.
IF NOT RFC_NO IS INITIAL.
* gb_tech_changed = 'X'.
ENDIF.
REFRESH IT_TRACE.
IF NOT IT_TRACE-OBJNR IS INITIAL.
APPEND IT_TRACE.
ENDIF.
ENDCASE.
ENDFORM. " PUSHBOTTONS
*&---------------------------------------------------------------------*
*& Form CHANGE_ICONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM CHANGE_ICONS .
IF LD_RFCGR IS INITIAL.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
NAME = 'ICON_ENTER_MORE'
INFO = SD_TEXT_NGW
IMPORTING
RESULT = PU_LIST.
ELSE.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
NAME = 'ICON_DISPLAY_MORE'
INFO = SD_TEXT_NGW
IMPORTING
RESULT = PU_LIST.
ENDIF.
* clear icons if box was cleared
IF LIST IS INITIAL AND GB_LIST_CHANGED = 'X'.
CLEAR: GB_LIST_CHANGED, VAR_COS, VAR_WIP.
ENDIF.
* clear icons if box was cleared
IF LIST IS INITIAL AND GB_LIST_CHANGED = 'X'.
CLEAR: GB_LIST_CHANGED, VAR_COS, VAR_WIP.
ENDIF.
* set correct icons on pushbuttons
IF GB_LIST_CHANGED = 'X'.
WRITE: ICON_DISPLAY_MORE TO PU_LIST AS ICON.
WRITE: TEXT-PU1 TO PU_LIST+4.
ELSE.
WRITE: ICON_ENTER_MORE TO PU_LIST AS ICON.
WRITE: TEXT-PU1 TO PU_LIST+4.
ENDIF.
IF GB_TECH_CHANGED = 'X'.
WRITE: ICON_DISPLAY_MORE TO PU_TECH AS ICON.
WRITE: TEXT-PU2 TO PU_TECH+4.
ELSE.
WRITE: ICON_ENTER_MORE TO PU_TECH AS ICON.
WRITE: TEXT-PU2 TO PU_TECH+4.
ENDIF.
ENDFORM. " CHANGE_ICONS
*&---------------------------------------------------------------------*
*& Form CHECK_VALUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM CHECK_VALUE .
**Company Code / Plant Existency Check
IF P_WERKS IS NOT INITIAL.
SELECT SINGLE BUKRS BWKEY FROM T001K
INTO (T_BUKRS ,T_BWKEY)
WHERE BUKRS = P_BUKRS
AND BWKEY = P_WERKS-LOW.
IF SY-SUBRC <> 0.
MESSAGE E001(/TDK/CB00020) .
ENDIF.
ELSE.
SELECT SINGLE BUKRS FROM T001K
INTO T_BUKRS
WHERE BUKRS = P_BUKRS.
IF SY-SUBRC <> 0.
MESSAGE E001(/TDK/CB00020) .
ENDIF.
ENDIF.
*Controll Regulation for Data Selection
IF P_GROUP <> ''.
IF ( P_BU <> '' OR P_SBU <> '' OR P_CBU <> '' OR P_PRCTR <> '').
P_BU = ''.
P_CBU = ''.
P_SBU = ''.
P_PRCTR = ''.
MESSAGE E003(/TDK/CB00020) WITH P_GROUP .
ENDIF.
ELSEIF P_PRCTR <>''.
IF ( P_BU <> '' OR P_CBU <> '' OR P_SBU <> '').
P_BU = ''.
P_CBU = ''.
P_SBU = ''.
MESSAGE E003(/TDK/CB00020) WITH P_PRCTR .
ENDIF.
ELSEIF P_SBU <> ''.
IF ( P_BU <> '' OR P_CBU <> '' ).
P_BU = ''.
P_CBU = ''.
MESSAGE E003(/TDK/CB00020) WITH P_SBU .
ENDIF.
ELSEIF P_CBU <> ''.
IF P_BU <> ''.
P_BU = ''.
MESSAGE E003(/TDK/CB00020) WITH P_CBU .
ENDIF.
ENDIF.
ENDFORM. " CHECK_VALUE
*&---------------------------------------------------------------------*
*& Form PRE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM PRE_DATA .
SELECT SINGLE KOKRS FROM TKA02 INTO T_KOKRS
WHERE BUKRS = P_BUKRS.
IF R1 = 'X'.
IF P_VERSA <> ''.
SELECT SINGLE * FROM TKKAP
WHERE KOKRS = T_KOKRS
AND VERSA = P_VERSA.
IF SY-SUBRC <> 0.
MESSAGE E004(/TDK/CB00020).
ENDIF.
ENDIF.
IF P_VAR <> ''.
SELECT SINGLE * FROM LTDX
WHERE RELID = 'LT'
AND REPORT = 'SAPKKA07'
AND ( USERNAME = '' OR USERNAME = SY-UNAME )
AND VARIANT = P_VAR.
IF SY-SUBRC <> 0.
MESSAGE E005(/TDK/CB00020).
ENDIF.
ENDIF.
ELSEIF R2 = 'X'.
IF P_AWVRS <> ''.
SELECT SINGLE * FROM TKV09
WHERE KOKRS = T_KOKRS
AND AWVRS = P_AWVRS.
IF SY-SUBRC <> 0.
MESSAGE E006(/TDK/CB00020).
ENDIF.
ENDIF.
ELSE.
IF LIST = 'X'.
IF VAR_COS <> ''.
SELECT SINGLE * FROM LTDX
WHERE RELID = 'LT'
AND REPORT = 'SAPLKALV'
AND HANDLE = 'COST'
AND ( USERNAME = '' OR USERNAME = SY-UNAME )
AND VARIANT = VAR_COS.
IF SY-SUBRC <> 0.
MESSAGE E005(/TDK/CB00020).
ENDIF.
ENDIF.
IF VAR_WIP <> ''.
SELECT SINGLE * FROM LTDX
WHERE RELID = 'LT'
AND REPORT = 'SAPLKALV'
AND HANDLE = 'WIP'
AND ( USERNAME = '' OR USERNAME = SY-UNAME )
AND VARIANT = VAR_WIP.
IF SY-SUBRC <> 0.
MESSAGE E005(/TDK/CB00020).
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " PRE_DATA
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM PROCESS_DATA .
**Get First day of fiscal year and period
CALL FUNCTION 'BAPI_COAREA_GETPERIODLIMITS'
EXPORTING
CONTROLLINGAREAID = T_KOKRS
FISCAL_PERIOD = P_MONAT
FISCAL_YEAR = P_GJAHR
IMPORTING
FIRST_DAY_OF_PERIOD = T_FIRST_DAY
LAST_DAY_OF_PERIOD = T_LAST_DAY
* LAST_NORMAL_PERIOD =
* RETURN =
.
IF SY-SUBRC <> 0.
MESSAGE E007(/TDK/CB00020).
ENDIF.
**Get Order List of Selected Plant
IF T_BWKEY <> '' AND P_PRCTR <> ''.
SELECT * FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE ORDER_TAB
WHERE AUTYP <> '01'
AND WERKS = T_BWKEY
AND LOEKZ = ''
AND PRCTR = P_PRCTR.
IF ORDER_TAB[] IS INITIAL.
MESSAGE E008(/TDK/CB00020).
ENDIF.
ELSEIF T_BWKEY = '' AND P_PRCTR <> '' .
SELECT * FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE ORDER_TAB
WHERE AUTYP <> '01'
AND LOEKZ = ''
AND PRCTR = P_PRCTR.
IF ORDER_TAB[] IS INITIAL.
MESSAGE E008(/TDK/CB00020).
ENDIF.
ELSEIF T_BWKEY = '' AND P_PRCTR = '' .
SELECT * FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE ORDER_TAB
WHERE AUTYP <> '01'
AND LOEKZ = ''.
IF ORDER_TAB[] IS INITIAL.
MESSAGE E008(/TDK/CB00020).
ENDIF.
ELSEIF T_BWKEY <> '' AND P_PRCTR = '' .
SELECT * FROM AUFK
INTO CORRESPONDING FIELDS OF TABLE ORDER_TAB
WHERE AUTYP <> '01'
AND WERKS = T_BWKEY
AND LOEKZ = ''.
IF ORDER_TAB[] IS INITIAL.
MESSAGE E008(/TDK/CB00020).
ENDIF.
ENDIF.
LOOP AT ORDER_TAB.
SELECT * FROM AFKO
APPENDING CORRESPONDING FIELDS OF TABLE ORDER_HEAD
WHERE AUFNR = ORDER_TAB-AUFNR.
* AND APRIO IN P_APRIO.
ENDLOOP .
IF ORDER_HEAD[] IS INITIAL.
MESSAGE E009(/TDK/CB00020).
ENDIF.
* MESSAGE E010(/TDK/CB00020) WITH ORDER_TAB-AUFNR P_APRIO.
* ELSE.
* IF AFKO-APRIO = P_APRIO-LOW.
LOOP AT ORDER_TAB.
READ TABLE ORDER_HEAD WITH KEY AUFNR = ORDER_TAB-AUFNR.
IF SY-SUBRC = 0.
IF ORDER_HEAD-APRIO IN P_APRIO.
ORDER_TAB-APRIO = ORDER_HEAD-APRIO.
SELECT SINGLE * FROM AFPO
WHERE AUFNR = ORDER_TAB-AUFNR.
IF SY-SUBRC <> 0.
MESSAGE E011(/TDK/CB00020).
ELSE.
ORDER_TAB-MATNR = AFPO-MATNR.
ENDIF.
MODIFY ORDER_TAB.
ELSE.
DELETE ORDER_TAB.
MESSAGE S010(/TDK/CB00020) WITH ORDER_TAB-AUFNR P_APRIO-LOW.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR ORDER_TAB .
SORT ORDER_TAB BY MATNR.
LOOP AT ORDER_TAB.
WA_MATNR-MATNR = ORDER_TAB-MATNR.
APPEND WA_MATNR TO T_MATNR.
CLEAR WA_MATNR.
ENDLOOP.
CLEAR ORDER_TAB .
SORT T_MATNR BY MATNR ASCENDING.
DELETE ADJACENT DUPLICATES FROM T_MATNR COMPARING MATNR.
*Get Material Organization
CALL FUNCTION '/TDK/C_MAT_ORG'
EXPORTING
I_PATTERN = '1'
I_BUKRS = P_BUKRS
IT_MATNR = T_MATNR
I_DATE = T_LAST_DAY
I_SETNAME = '0000T_T'
* I_BU =
IMPORTING
ET_MAT_HIER = T_MAT_HIER
EXCEPTIONS
INVALID_MATERIAL = 1
INVALID_ITEM_GROUP = 2
INVALID_SETNAME = 3
INVALID_BU = 4
INVALID_SEGMENT = 5
INVALID_PARAMETER = 6
INVALID_COMPANY = 7
OTHERS = 8
.
IF SY-SUBRC <> 0.
MESSAGE E012(/TDK/CB00020).
ENDIF.
LOOP AT T_MAT_HIER INTO TH_MAT_HIER.
*Data Limitation(Material / Organization)
IF P_GROUP <> ''.
IF TH_MAT_HIER-/EPCOS/TDKKL = P_GROUP.
MOVE-CORRESPONDING TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ELSE.
DELETE ORDER_TAB WHERE MATNR = TH_MAT_HIER-MATNR.
ENDIF.
ELSEIF P_BU <> ''.
IF TH_MAT_HIER-ORG_LV3 = P_BU.
MOVE-CORRESPONDING TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ELSE.
DELETE ORDER_TAB WHERE MATNR = TH_MAT_HIER-MATNR.
ENDIF.
ELSEIF P_CBU <> ''.
IF TH_MAT_HIER-ORG_LV4 = P_CBU.
MOVE-CORRESPONDING TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ELSE.
DELETE ORDER_TAB WHERE MATNR = TH_MAT_HIER-MATNR.
ENDIF.
ELSEIF P_SBU <> '' .
IF TH_MAT_HIER-SEGMENT = P_SBU .
MOVE-CORRESPONDING TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ELSE.
DELETE ORDER_TAB WHERE MATNR = TH_MAT_HIER-MATNR.
ENDIF.
ELSE.
MOVE TH_MAT_HIER TO WA_MAT_HIER.
APPEND WA_MAT_HIER.
ENDIF.
ENDLOOP.
IF WA_MAT_HIER[] IS INITIAL.
MESSAGE E013(/TDK/CB00020).
ENDIF.
LOOP AT ORDER_TAB.
LOOP AT WA_MAT_HIER WHERE MATNR = ORDER_TAB-MATNR.
MOVE-CORRESPONDING ORDER_TAB TO ITAB.
ITAB-ORG_LV3 = WA_MAT_HIER-ORG_LV3.
ITAB-ORG_LV4 = WA_MAT_HIER-ORG_LV4.
ITAB-SEGMENT = WA_MAT_HIER-SEGMENT.
ITAB-/EPCOS/TDKKL = WA_MAT_HIER-/EPCOS/TDKKL.
APPEND ITAB.
ENDLOOP.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form OUTPUT_DATA_B
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM OUTPUT_DATA_B.
LOOP AT ITAB.
IF ITAB-AUFNR IS NOT INITIAL.
S_AUFNR-SIGN = 'I'.
S_AUFNR-OPTION = 'EQ'.
S_AUFNR-LOW = ITAB-AUFNR.
APPEND S_AUFNR.
ENDIF.
IF ITAB-WERKS IS NOT INITIAL.
S_WERKS-SIGN = 'I'.
S_WERKS-OPTION = 'EQ'.
S_WERKS-LOW = ITAB-WERKS.
APPEND S_WERKS.
ENDIF.
DELETE ADJACENT DUPLICATES FROM S_WERKS.
ENDLOOP.
* Job open
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
JOBNAME = JOBNAME
SDLSTRTDT = SY-DATUM
SDLSTRTTM = SY-UZEIT
IMPORTING
JOBCOUNT = JOBCOUNT
EXCEPTIONS
CANT_CREATE_JOB = 01
INVALID_JOB_DATA = 02
JOBNAME_MISSING = 03.
IF SY-SUBRC NE 0.
"error processing
ENDIF.
IF R1 = 'X'.
IF R1_2 = 'X' AND P_VERSA <> ''.
SUBMIT SAPKKA07 USING SELECTION-SCREEN '1000' AND RETURN
WITH ABGRWERK IN S_WERKS
WITH INCFAUFT = C1
WITH INCPKOSA = C2
WITH INCPIAUF = C3
WITH ABGRAUFN IN S_AUFNR
WITH ABGRMONA = P_MONAT
WITH ABGRJAHR = P_GJAHR
WITH ABGRVERS-LOW = P_VERSA
WITH WITHIMSG = R1_C
WITH OBJ_LST = R1_C1
WITH FEHLAUFT = R1_C2
WITH NO_0_WIP = R1_C3
WITH P_CCCURR = 'X'
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ELSEIF R1_1 = 'X'.
SUBMIT SAPKKA07 USING SELECTION-SCREEN '1000' AND RETURN
WITH ABGRWERK IN S_WERKS
WITH INCFAUFT = C1
WITH INCPKOSA = C2
WITH INCPIAUF = C3
WITH ABGRAUFN IN S_AUFNR
WITH ABGRMONA = P_MONAT
WITH ABGRJAHR = P_GJAHR
WITH WITHIMSG = R1_C
WITH OBJ_LST = R1_C1
WITH FEHLAUFT = R1_C2
WITH NO_0_WIP = R1_C3
WITH P_CCCURR = 'X'
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ENDIF.
ELSEIF R2 = 'X'.
IF R2_2 = 'X' AND P_AWVRS <> ''.
SUBMIT RKKKS1N0 USING SELECTION-SCREEN '1000' AND RETURN
WITH WERKS IN S_WERKS
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH AUFNR IN S_AUFNR
WITH PA_POPER = P_MONAT
WITH PA_GJAHR = P_GJAHR
WITH PA_AWVSE = P_AWVRS
WITH RFCPROC = R2_C1
WITH PA_LISTF = R2_C2
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ELSEIF R2_1 = 'X'.
SUBMIT RKKKS1N0 USING SELECTION-SCREEN '1000' AND RETURN
WITH WERKS IN S_WERKS
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH AUFNR IN S_AUFNR
WITH PA_POPER = P_MONAT
WITH PA_GJAHR = P_GJAHR
WITH RFCPROC = R2_C1
WITH PA_LISTF = R2_C2
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ENDIF.
ELSEIF R3 = 'X'.
IF P_PERIO <> ''.
SUBMIT RKO7CO88 USING SELECTION-SCREEN '1000' AND RETURN
WITH WERKS IN S_WERKS
WITH AUFNR IN S_AUFNR
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH PERIO = P_MONAT
WITH GJAHR = P_GJAHR
WITH VAART = P_VAART
WITH BUPERIO = P_PERIO
WITH AUSF = R3_1
WITH STOR = R3_2
WITH TESTLAUF = R3_C1
WITH RFCPROC = R3_C2
WITH TDCHECK = R3_C3
WITH LIST = LIST
WITH VAR_COS = VAR_COS
WITH VAR_WIP = VAR_WIP
WITH ERRGR = ERRGR
WITH COUNT = COUNT
WITH OBJNR = IT_TRACE-OBJNR
WITH RFC_NO = RFC_NO
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ELSE.
SUBMIT RKO7CO88 USING SELECTION-SCREEN '1000' AND RETURN
WITH WERKS IN S_WERKS
WITH AUFNR IN S_AUFNR
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH PERIO = P_MONAT
WITH GJAHR = P_GJAHR
WITH VAART = P_VAART
WITH AUSF = R3_1
WITH STOR = R3_2
WITH TESTLAUF = R3_C1
WITH RFCPROC = R3_C2
WITH TDCHECK = R3_C3
WITH LIST = LIST
WITH VAR_COS = VAR_COS
WITH VAR_WIP = VAR_WIP
WITH ERRGR = ERRGR
WITH COUNT = COUNT
WITH OBJNR = IT_TRACE-OBJNR
WITH RFC_NO = RFC_NO
USER SY-UNAME
VIA JOB JOBNAME
NUMBER JOBCOUNT.
ENDIF.
ENDIF.
* Close job
STARTTIME-SDLSTRTDT = SY-DATUM + 1.
STARTTIME-SDLSTRTTM = '220000'.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
" event_id = starttime-eventid
" event_param = starttime-eventparm
" event_periodic = starttime-periodic
JOBCOUNT = JOBCOUNT
JOBNAME = JOBNAME
" laststrtdt = starttime-laststrtdt
" laststrttm = starttime-laststrttm
" prddays = 1
" prdhours = 0
" prdmins = 0
" prdmonths = 0
" prdweeks = 0
" sdlstrtdt = starttime-sdlstrtdt
" sdlstrttm = starttime-sdlstrttm
STRTIMMED = STARTTIMEIMMEDIATE
" targetsystem = host
EXCEPTIONS
CANT_START_IMMEDIATE = 01
INVALID_STARTDATE = 02
JOBNAME_MISSING = 03
JOB_CLOSE_FAILED = 04
JOB_NOSTEPS = 05
JOB_NOTEX = 06
LOCK_FAILED = 07
OTHERS = 99.
IF SY-SUBRC EQ 0.
"error processing
ENDIF.
ENDFORM. " OUTPUT_DATA_B
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2155 text
* -->P_2156 text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR T_BDC.
T_BDC-PROGRAM = PROGRAM.
T_BDC-DYNPRO = DYNPRO.
T_BDC-DYNBEGIN = 'X'.
APPEND T_BDC.
ENDFORM. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2160 text
* -->P_2161 text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR T_BDC.
T_BDC-FNAM = FNAM.
T_BDC-FVAL = FVAL.
APPEND T_BDC.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form OUTPUT_DATA_F
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM OUTPUT_DATA_F .
LOOP AT ITAB.
IF ITAB-AUFNR IS NOT INITIAL.
S_AUFNR-SIGN = 'I'.
S_AUFNR-OPTION = 'EQ'.
S_AUFNR-LOW = ITAB-AUFNR.
APPEND S_AUFNR.
ENDIF.
IF ITAB-WERKS IS NOT INITIAL.
S_WERKS-SIGN = 'I'.
S_WERKS-OPTION = 'EQ'.
S_WERKS-LOW = ITAB-WERKS.
APPEND S_WERKS.
ENDIF.
DELETE ADJACENT DUPLICATES FROM S_WERKS.
ENDLOOP.
IF R1 = 'X'.
IF R1_2 = 'X' AND P_VERSA <> ''.
SUBMIT SAPKKA07 USING SELECTION-SCREEN '1000'
WITH ABGRWERK IN S_WERKS
WITH INCFAUFT = C1
WITH INCPKOSA = C2
WITH INCPIAUF = C3
WITH ABGRAUFN IN S_AUFNR
WITH ABGRMONA = P_MONAT
WITH ABGRJAHR = P_GJAHR
WITH ABGRVERS-LOW = P_VERSA
WITH WITHIMSG = R1_C
WITH OBJ_LST = R1_C1
WITH FEHLAUFT = R1_C2
WITH NO_0_WIP = R1_C3
WITH P_CCCURR = 'X' AND RETURN.
ELSEIF R1_1 = 'X'.
SUBMIT SAPKKA07 USING SELECTION-SCREEN '1000'
WITH ABGRWERK IN S_WERKS
WITH INCFAUFT = C1
WITH INCPKOSA = C2
WITH INCPIAUF = C3
WITH ABGRAUFN IN S_AUFNR
WITH ABGRMONA = P_MONAT
WITH ABGRJAHR = P_GJAHR
WITH WITHIMSG = R1_C
WITH OBJ_LST = R1_C1
WITH FEHLAUFT = R1_C2
WITH NO_0_WIP = R1_C3
WITH P_CCCURR = 'X' AND RETURN.
ENDIF.
ELSEIF R2 = 'X'.
IF R2_2 = 'X' AND P_AWVRS <> ''.
SUBMIT RKKKS1N0 USING SELECTION-SCREEN '1000'
WITH WERKS IN S_WERKS
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH AUFNR IN S_AUFNR
WITH PA_POPER = P_MONAT
WITH PA_GJAHR = P_GJAHR
WITH PA_AWVSE = P_AWVRS
WITH RFCPROC = R2_C1
WITH PA_LISTF = R2_C2 AND RETURN.
ELSEIF R2_1 = 'X'.
SUBMIT RKKKS1N0 USING SELECTION-SCREEN '1000'
WITH WERKS IN S_WERKS
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH AUFNR IN S_AUFNR
WITH PA_POPER = P_MONAT
WITH PA_GJAHR = P_GJAHR
WITH RFCPROC = R2_C1
WITH PA_LISTF = R2_C2 AND RETURN.
ENDIF.
ELSEIF R3 = 'X'.
IF P_PERIO <> ''.
SUBMIT RKO7CO88 USING SELECTION-SCREEN '1000'
WITH WERKS IN S_WERKS
WITH AUFNR IN S_AUFNR
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH PERIO = P_MONAT
WITH GJAHR = P_GJAHR
WITH VAART = P_VAART
WITH BUPERIO = P_PERIO
WITH AUSF = R3_1
WITH STOR = R3_2
WITH TESTLAUF = R3_C1
WITH RFCPROC = R3_C2
WITH TDCHECK = R3_C3
WITH LIST = LIST
WITH VAR_COS = VAR_COS
WITH VAR_WIP = VAR_WIP
WITH ERRGR = ERRGR
WITH COUNT = COUNT
WITH OBJNR = IT_TRACE-OBJNR
WITH RFC_NO = RFC_NO AND RETURN.
ELSE.
SUBMIT RKO7CO88 USING SELECTION-SCREEN '1000'
WITH WERKS IN S_WERKS
WITH AUFNR IN S_AUFNR
WITH IN_FAUF = C1
WITH IN_PIAUF = C2
WITH IN_PKOSA = C3
WITH PERIO = P_MONAT
WITH GJAHR = P_GJAHR
WITH VAART = P_VAART
WITH AUSF = R3_1
WITH STOR = R3_2
WITH TESTLAUF = R3_C1
WITH RFCPROC = R3_C2
WITH TDCHECK = R3_C3
WITH LIST = LIST
WITH VAR_COS = VAR_COS
WITH VAR_WIP = VAR_WIP
WITH ERRGR = ERRGR
WITH COUNT = COUNT
WITH OBJNR = IT_TRACE-OBJNR
WITH RFC_NO = RFC_NO AND RETURN.
ENDIF.
ENDIF.
ENDFORM. " OUTPUT_DATA_F
*&---------------------------------------------------------------------*
*& Form BDC_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
*
*----------------------------------------------------------------------*
FORM BDC_DATA .
DATA: L_MODE TYPE C.
MOVE 'N' TO L_MODE.
*CREATE BDC FOR CHANGE CONTROLLING AREA IN SCREEN
REFRESH T_BDC.
CLEAR T_BDC.
* PERFORM BDC_DYNPRO USING 'SAPKKA07' '1000'.
* PERFORM BDC_FIELD USING 'BDC_CURSOR'
* 'ABGRAUFA-LOW'.
* PERFORM BDC_FIELD USING 'BDC_OKCODE'
* '=OKKS'.
* PERFORM BDC_FIELD USING 'ABGRMONA'
* P_MONAT.
* PERFORM BDC_FIELD USING 'ABGRJAHR'
* P_GJAHR.
* PERFORM BDC_DYNPRO USING 'SAPLSPO4' '0300'.
* PERFORM BDC_FIELD USING 'BDC_CURSOR'
* 'SVALD-VALUE(01)'.
* PERFORM BDC_FIELD USING 'BDC_OKCODE'
* '=COD1'.
* PERFORM BDC_FIELD USING 'SVALD-VALUE(01)'
* T_KOKRS.
* PERFORM BDC_DYNPRO USING 'SAPKKA07' '1000'.
* PERFORM BDC_FIELD USING 'BDC_OKCODE'
* '/EENDE'.
* PERFORM BDC_FIELD USING 'BDC_CURSOR'
* 'ABGRJAHR'.
*
* CALL TRANSACTION '/TDK/CT0210'
* USING T_BDC
* MODE L_MODE
* UPDATE 'S'
* MESSAGES INTO T_MSG.
PERFORM BDC_DYNPRO USING 'SAPLKO71' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/ESKRS'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LKO74-GJAHR'.
PERFORM BDC_DYNPRO USING 'SAPLSPO4' '0300'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'SVALD-VALUE(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=COD1'.
PERFORM BDC_FIELD USING 'SVALD-VALUE(01)'
T_KOKRS.
PERFORM BDC_DYNPRO USING 'SAPLKO71' '1000'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LKO74-GJAHR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'LKO74-PERIO'
P_MONAT.
PERFORM BDC_FIELD USING 'LKO74-GJAHR'
P_GJAHR.
PERFORM BDC_DYNPRO USING 'SAPLKO71' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/EERET'.
CALL TRANSACTION 'CO88'
USING T_BDC
MODE L_MODE
UPDATE 'S'
MESSAGES INTO T_MSG.
ENDFORM. " BDC_DATA
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13973563/viewspace-752727/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13973563/viewspace-752727/