REPORT zhr_quota_update.
TABLES: pa0000.
TYPES: BEGIN OF ty_pa0000,
pernr TYPE pa0000-pernr,
begda TYPE pa0000-begda,
endda TYPE pa0000-endda,
massn TYPE pa0000-massn,
massg TYPE pa0000-massg,
stat2 TYPE pa0000-stat2,
END OF ty_pa0000.
TYPES: BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
begda TYPE pa0001-begda,
endda TYPE pa0001-endda,
END OF ty_pa0001.
TYPES: BEGIN OF ty_pa0016,
pernr TYPE pa0016-pernr,
begda TYPE pa0016-begda,
endda TYPE pa0016-endda,
zquota TYPE pa0016-zquota,
END OF ty_pa0016.
TYPES: BEGIN OF ty_pa2001,
pernr TYPE pa2001-pernr,
begda TYPE pa2001-begda,
endda TYPE pa2001-endda,
awart TYPE pa2001-awart,
abrtg TYPE pa2001-abrtg,
END OF ty_pa2001.
TYPES: BEGIN OF ty_prop_values.
INCLUDE STRUCTURE pprop.
TYPES: END OF ty_prop_values.
TYPES: BEGIN OF ty_mod_values.
INCLUDE STRUCTURE pskey.
TYPES: END OF ty_mod_values.
TYPES: BEGIN OF ty_t508a.
INCLUDE STRUCTURE t508a.
TYPES:END OF ty_t508a.
TYPES: BEGIN OF ty_t559e,
qtype TYPE t559e-qtype,
rulno TYPE t559e-rulno,
lvnum TYPE t559e-lvnum,
END OF ty_t559e.
TYPES: BEGIN OF ty_pa2006,
pernr TYPE pa2006-pernr,
subty TYPE pa2006-subty,
begda TYPE pa2006-begda,
endda TYPE pa2006-endda,
ktart TYPE pa2006-ktart,
END OF ty_pa2006.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: it_prop_values TYPE TABLE OF ty_prop_values WITH HEADER LINE,
it_mod_values TYPE TABLE OF ty_mod_values WITH HEADER LINE,
it_pa0000 TYPE TABLE OF ty_pa0000 WITH HEADER LINE,
it_pa0001 TYPE TABLE OF ty_pa0001 WITH HEADER LINE,
it_pa0016 TYPE TABLE OF ty_pa0016 WITH HEADER LINE,
it_pa2001 TYPE TABLE OF ty_pa2001 WITH HEADER LINE, "DEVK906397
it_pa2006 TYPE TABLE OF ty_pa2006 WITH HEADER LINE, "DEVK906397
it_t559e TYPE TABLE OF ty_t559e WITH HEADER LINE,
it_return TYPE bapireturn.
DATA: i_month TYPE fcmnr,
i_year TYPE gjahr,
i_date TYPE sy-datum,
e_first_day TYPE sy-datum,
e_last_day TYPE sy-datum,
v_date1 TYPE sy-datum,
v_date2 TYPE sy-datum,
v_date3 TYPE sy-datum,
v_date4 TYPE sy-datum,
v_first TYPE sy-datum,
v_last TYPE sy-datum,
v_date5 TYPE vtbbewe-dbervon,
v_date6 TYPE vtbbewe-dbervon,
v_days(10) TYPE c,
v_months(10) TYPE c,
v_years(10) TYPE c,
v_days1 TYPE vtbbewe-atage,
v_months1 TYPE vtbbewe-atage,
v_years1 TYPE vtbbewe-atage,
v_mult TYPE p2006-anzhl,
v_val TYPE char10,
v_total(10) TYPE c,
v_mdate1 TYPE sy-datum,
v_mdate2 TYPE sy-datum,
v_mdate3 TYPE sy-datum.
data: v_mdate6 TYPE sy-datum,
v_mdate7 TYPE sy-datum,
v_mdate8 TYPE sy-datum,
v_mdate9 TYPE sy-datum,
v_ext(15) TYPE c,
v_quota1 TYPE t559e-lvnum,
v_quota2 TYPE t559e-lvnum,
v_quota3 TYPE t559e-lvnum.
ranges: r_massn for p0000-massn,
r_massg for p0000-massg.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_pernr FOR pa0000-pernr.
PARAMETERS : p_date TYPE sy-datum .
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
p_date = sy-datum.
START-OF-SELECTION.
SELECT qtype
rulno
lvnum
FROM t559e
INTO TABLE it_t559e
WHERE mopgk = '1'
AND mozko = '01'
AND mobde = '01'.
IF sy-subrc = 0.
SORT it_t559e BY qtype.
ENDIF.
READ TABLE it_t559e WITH KEY qtype = '03'.
IF sy-subrc = 0.
v_quota1 = it_t559e-lvnum.
ENDIF.
READ TABLE it_t559e WITH KEY qtype = '04'.
IF sy-subrc = 0.
v_quota2 = it_t559e-lvnum.
ENDIF.
READ TABLE it_t559e WITH KEY qtype = '24'.
IF sy-subrc = 0.
v_quota3 = it_t559e-lvnum.
ENDIF.
r_massn-low = '01'.
r_massn-sign = 'I'.
r_massn-option = 'EQ'.
APPEND r_massn.
r_massn-low = '28'.
APPEND r_massn.
r_massn-low = '27'.
APPEND r_massn.
r_massg-low = '01'.
r_massg-sign = 'I'.
r_massg-option = 'EQ'.
APPEND r_massg.
r_massg-low = '28'.
APPEND r_massg.
r_massg-low = '27'.
APPEND r_massg.
r_massg-low = '40'.
APPEND r_massg.
SELECT pernr
begda
endda
massn
massg
FROM pa0000
INTO TABLE it_pa0000
WHERE pernr IN s_pernr
AND massn IN r_massn
AND massg IN r_massg
AND stat2 = '3'.
IF sy-subrc = 0.
SORT it_pa0000 BY pernr.
SELECT pernr
begda
endda
FROM pa0001
INTO TABLE it_pa0001
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr.
IF sy-subrc = 0.
SORT it_pa0001 BY pernr.
DELETE ADJACENT DUPLICATES FROM it_pa0001 COMPARING pernr.
ENDIF.
SELECT pernr
begda
endda
zquota
FROM pa0016
INTO TABLE it_pa0016
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr
AND endda = '99991231'.
IF sy-subrc = 0 .
SORT it_pa0016 BY pernr.
ENDIF.
SELECT pernr
begda
endda
awart
abrtg
FROM pa2001
INTO TABLE it_pa2001
FOR ALL ENTRIES IN it_pa0000
WHERE pernr = it_pa0000-pernr
AND subty = '0100'
OR subty = '0200'.
IF sy-subrc = 0.
SORT it_pa2001 BY pernr.
ENDIF.
SELECT pernr
subty
begda
endda
ktart
FROM pa2006
INTO TABLE it_pa2006
FOR ALL ENTRIES IN it_pa0016
WHERE pernr = it_pa0016-pernr
AND begda LE it_pa0016-endda
AND endda GE it_pa0016-begda.
IF sy-subrc = 0.
SORT it_pa2006 BY pernr.
ENDIF.
ENDIF.
END-OF-SELECTION.
v_date1+0(4) = sy-datum+0(4).
v_date1+4(4) = '0101'.
CALL FUNCTION 'OIL_MONTH_GET_FIRST_LAST'
EXPORTING
i_month = '01'
i_year = sy-datum+0(4)
i_date = sy-datum
IMPORTING
e_first_day = e_first_day
e_last_day = v_date1
EXCEPTIONS
wrong_date = 1
OTHERS = 2.
v_date2+0(4) = sy-datum+0(4).
v_date2+4(4) = '1212'.
CALL FUNCTION 'OIL_MONTH_GET_FIRST_LAST'
EXPORTING
i_month = '12'
i_year = sy-datum+0(4)
i_date = sy-datum
IMPORTING
e_first_day = v_date2
e_last_day = e_last_day
EXCEPTIONS
wrong_date = 1
OTHERS = 2.
v_mdate1+4(4) = e_first_day+0(4).
v_mdate1+2(2) = e_first_day+4(2).
v_mdate1+0(2) = e_first_day+6(2).
v_mdate2+4(4) = e_last_day+0(4).
v_mdate2+2(2) = e_last_day+4(2).
v_mdate2+0(2) = e_last_day+6(2).
v_mdate7+4(4) = '9999'.
v_mdate7+2(2) = '12'.
v_mdate7+0(2) = '31'.
IF p_date = sy-datum.
v_mdate6+4(4) = sy-datum+0(4).
v_mdate6+2(2) = sy-datum+4(2).
v_mdate6+0(2) = sy-datum+6(2).
ELSE.
v_mdate6+4(4) = p_date+0(4).
v_mdate6+2(2) = p_date+4(2).
v_mdate6+0(2) = p_date+6(2).
ENDIF.
LOOP AT it_pa0001.
READ TABLE it_pa0016 WITH KEY pernr = it_pa0001-pernr.
IF sy-subrc = 0.
v_mdate3+4(4) = it_pa0016-begda+0(4).
v_mdate3+2(2) = it_pa0016-begda+4(2).
v_mdate3+0(2) = it_pa0016-begda+6(2).
v_date3 = it_pa0016-begda.
v_date4 = sy-datum.
CALL FUNCTION 'OIL_MONTH_GET_FIRST_LAST'
EXPORTING
i_month = v_date3+4(2)
i_year = v_date3+0(4)
i_date = v_date3
IMPORTING
e_first_day = v_date3
e_last_day = v_date4
EXCEPTIONS
wrong_date = 1
OTHERS = 2.
v_date5 = it_pa0016-begda.
v_date6 = sy-datum.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
i_date_from = v_date5
i_date_to = v_date6
i_flg_separate = 'X'
IMPORTING
e_days = v_days1
e_months = v_months1
e_years = v_years1.
IF v_date5 = v_date6.
v_days1 = 1.
ENDIF.
v_days1 = v_days1 + v_months1 * 30 + v_years1 * 365.
IF v_years1 GT 5.
v_mult = it_pa0016-zquota / 12.
ENDIF.
LOOP AT it_pa2001 WHERE pernr = it_pa0001-pernr.
v_total = v_total + it_pa2001-abrtg.
ENDLOOP.
v_mdate8+4(4) = it_pa0016-begda+0(4).
v_mdate8+2(2) = it_pa0016-begda+4(2).
v_mdate8+0(2) = it_pa0016-begda+6(2).
v_mdate9+4(4) = it_pa0016-endda+0(4).
v_mdate9+2(2) = it_pa0016-endda+4(2).
v_mdate9+0(2) = it_pa0016-endda+6(2).
LOOP AT it_pa2006 WHERE pernr = it_pa0016-pernr
AND subty = '03'
AND begda GE it_pa0016-begda.
ENDLOOP.
IF sy-subrc ne 0.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
PERFORM bdc_field USING 'RP50G-PERNR'
it_pa0001-pernr.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
PERFORM bdc_field USING 'RP50G-BEGDA'
v_mdate8.
PERFORM bdc_field USING 'RP50G-ENDDA'
v_mdate9.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-SUBTY'.
PERFORM bdc_field USING 'RP50G-CHOIC'
'2006'.
PERFORM bdc_field USING 'RP50G-SUBTY'
'03'.
PERFORM bdc_dynpro USING 'MP200000' '2250'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P2006-DEEND'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P2006-BEGDA'
v_mdate8.
PERFORM bdc_field USING 'P2006-ENDDA'
v_mdate9.
PERFORM bdc_field USING 'P2006-KTART'
'03'.
v_val = v_quota1.
CONDENSE v_val.
v_mult = v_val+0(5).
PERFORM bdc_field USING 'P2006-ANZHL'
v_mult.
PERFORM bdc_field USING 'P2006-DESTA'
v_mdate8.
PERFORM bdc_field USING 'P2006-DEEND'
v_mdate9.
PERFORM bdc_transaction USING 'PA30'.
ENDIF.
wait up to 5 seconds.
refresh bdcdata.
v_mult = v_mult - v_total.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
PERFORM bdc_field USING 'RP50G-PERNR'
it_pa0001-pernr.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
IF e_first_day GT it_pa0016-begda.
PERFORM bdc_field USING 'RP50G-BEGDA'
v_mdate1.
ELSE.
PERFORM bdc_field USING 'RP50G-BEGDA'
v_mdate3.
ENDIF.
PERFORM bdc_field USING 'RP50G-ENDDA'
v_mdate2.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-SUBTY'.
PERFORM bdc_field USING 'RP50G-CHOIC'
'2006'.
PERFORM bdc_field USING 'RP50G-SUBTY'
'01'.
PERFORM bdc_dynpro USING 'MP200000' '2250'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P2006-DEEND'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
IF e_first_day GT it_pa0016-begda.
PERFORM bdc_field USING 'P2006-BEGDA'
v_mdate1.
ELSE.
PERFORM bdc_field USING 'P2006-BEGDA'
v_mdate3.
ENDIF.
PERFORM bdc_field USING 'P2006-ENDDA'
v_mdate2.
PERFORM bdc_field USING 'P2006-KTART'
'01'.
v_val = v_mult.
CONDENSE v_val.
v_mult = v_val+0(5).
PERFORM bdc_field USING 'P2006-ANZHL'
v_mult.
IF e_first_day GT it_pa0016-begda.
PERFORM bdc_field USING 'P2006-DESTA'
v_mdate6.
ELSE.
PERFORM bdc_field USING 'P2006-DESTA'
v_mdate6.
ENDIF.
PERFORM bdc_field USING 'P2006-DEEND'
v_mdate7.
PERFORM bdc_transaction USING 'PA30'.
refresh bdcdata.
wait up to 5 seconds.
LOOP AT it_pa2006 WHERE pernr = it_pa0016-pernr
AND subty = '04'
AND begda GE it_pa0016-begda.
ENDLOOP.
IF sy-subrc ne 0.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
PERFORM bdc_field USING 'RP50G-PERNR'
it_pa0001-pernr.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
PERFORM bdc_field USING 'RP50G-BEGDA'
v_mdate8.
PERFORM bdc_field USING 'RP50G-ENDDA'
v_mdate9.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-SUBTY'.
PERFORM bdc_field USING 'RP50G-CHOIC'
'2006'.
PERFORM bdc_field USING 'RP50G-SUBTY'
'04'.
PERFORM bdc_dynpro USING 'MP200000' '2250'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P2006-DEEND'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P2006-BEGDA'
v_mdate8.
PERFORM bdc_field USING 'P2006-ENDDA'
v_mdate9.
PERFORM bdc_field USING 'P2006-KTART'
'04'.
v_val = v_quota2.
CONDENSE v_val.
v_mult = v_val+0(5).
PERFORM bdc_field USING 'P2006-ANZHL'
v_mult.
PERFORM bdc_field USING 'P2006-DESTA'
v_mdate8.
PERFORM bdc_field USING 'P2006-DEEND'
v_mdate9.
PERFORM bdc_transaction USING 'PA30'.
ENDIF.
wait up to 5 seconds.
refresh bdcdata.
LOOP AT it_pa2006 WHERE pernr = it_pa0016-pernr
AND subty = '24'
AND begda GE it_pa0016-begda.
ENDLOOP.
IF sy-subrc ne 0.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
PERFORM bdc_field USING 'RP50G-PERNR'
it_pa0001-pernr.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
PERFORM bdc_field USING 'RP50G-BEGDA'
v_mdate8.
PERFORM bdc_field USING 'RP50G-ENDDA'
v_mdate9.
PERFORM bdc_field USING 'BDC_CURSOR'
'RP50G-SUBTY'.
PERFORM bdc_field USING 'RP50G-CHOIC'
'2006'.
PERFORM bdc_field USING 'RP50G-SUBTY'
'24'.
PERFORM bdc_dynpro USING 'MP200000' '2250'.
PERFORM bdc_field USING 'BDC_CURSOR'
'P2006-DEEND'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P2006-BEGDA'
v_mdate8.
PERFORM bdc_field USING 'P2006-ENDDA'
v_mdate9.
PERFORM bdc_field USING 'P2006-KTART'
'24'.
v_val = v_quota3.
CONDENSE v_val.
v_mult = v_val+0(5).
PERFORM bdc_field USING 'P2006-ANZHL'
v_mult.
PERFORM bdc_field USING 'P2006-DESTA'
v_mdate8.
PERFORM bdc_field USING 'P2006-DEEND'
v_mdate9.
PERFORM bdc_transaction USING 'PA30'.
wait up to 5 seconds.
ENDIF.
refresh bdcdata.
ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
IF fval <> space.
CLEAR bdcdata.
IF fnam = 'P2006-ANZHL'.
bdcdata-fnam = fnam.
v_val = fval.
REPLACE ALL OCCURRENCES OF '.' IN v_val WITH ','.
bdcdata-fval = v_val.
ELSE.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
ENDIF.
APPEND bdcdata.
ENDIF.
ENDFORM. "BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_TRANSACTION
*----------------------------------------------------------------------*
FORM bdc_transaction USING value(p_0741).
CALL TRANSACTION p_0741 USING bdcdata
MODE 'A'
UPDATE 'A'
MESSAGES INTO messtab.
ENDFORM. " BDC_TRANSACTION
Here you can find examples and sample programs related to ABAP Report Programs, ALV Grid/List Programs, BDC, HR ABAP, Function Modules, BAPIs, BADIs, Smartforms, SapScripts, etc.
Google Search - Blog...........
SAP ABAP - BDC For PO13 In HR Module.
report ZHR_MMG_BDC_REPORTING_UPLOAD
no standard page heading line-size 255.
DATA: I_BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE,
I_ERROR TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME OBLIGATORY,
P_MODE(1) DEFAULT 'A'.
SELECTION-SCREEN : BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETER: PBROW_HD TYPE I default 1, PEROW_HD TYPE I, PBCOL_HD TYPE i default 1, PECOL_HD TYPE I default 2.
SELECTION-SCREEN : END OF BLOCK BLK1.
DATA: T_EXCEL LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA: BEGIN of record occurs 0,
SEARK(8),
SOBID(8),
end of record.
DATA: V_FILENAME LIKE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
START-OF-SELECTION.
PERFORM UPLOAD.
PERFORM BDC.
*&---------------------------------------------------------------------*
*& Form UPLOAD
*----------------------------------------------------------------------*
FORM UPLOAD .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = PBCOL_HD
I_BEGIN_ROW = PBROW_HD
I_END_COL = PECOL_HD
I_END_ROW = PEROW_HD
TABLES
INTERN = T_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
LOOP AT T_EXCEL.
CASE T_EXCEL-COL.
WHEN 1. MOVE T_EXCEL-VALUE TO RECORD-SEARK.
WHEN 2. MOVE T_EXCEL-VALUE TO RECORD-SOBID.
ENDCASE.
AT END OF ROW.
APPEND RECORD.
CLEAR RECORD.
ENDAT.
ENDLOOP.
ENDFORM. " UPLOAD
*&---------------------------------------------------------------------*
*& Form BDC
*----------------------------------------------------------------------*
FORM BDC .
loop at record.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_CURSOR'
'PM0D1-SEARK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark. " '50000287'.
perform bdc_field using 'PM0D1-TIMR6'
'X'.
perform bdc_field using 'PPHDR-BEGDA'
'07.07.2010'.
perform bdc_field using 'PPHDR-ENDDA'
'31.12.9999'.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_OKCODE'
'=INSE'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark."'50000287'.
perform bdc_field using 'BDC_CURSOR'
'PPHDR-BEGDA'.
perform bdc_field using 'PM0D1-TIMR6'
'X'.
perform bdc_field using 'PPHDR-BEGDA'
'01.07.2010'.
perform bdc_field using 'PPHDR-ENDDA'
'31.12.9999'.
perform bdc_field using 'MARKFELD(02)'
'X'.
perform bdc_dynpro using 'MP100100' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P1001-SOBID'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'P1001-BEGDA'
'01.07.2010'.
perform bdc_field using 'P1001-ENDDA'
'31.12.9999'.
perform bdc_field using 'P1001-RSIGN'
'a'.
perform bdc_field using 'P1001-RELAT'
'002'.
perform bdc_field using 'P1001-SCLAS'
'S'.
perform bdc_field using 'P1001-SOBID'
record-sobid."'50000288'.
perform bdc_dynpro using 'MP100100' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P1001-BEGDA'.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.
perform bdc_field using 'P1001-BEGDA'
'01.07.2010'.
perform bdc_field using 'P1001-ENDDA'
'31.12.9999'.
perform bdc_field using 'P1001-RSIGN'
'A'.
perform bdc_field using 'P1001-RELAT'
'002'.
perform bdc_field using 'P1001-SCLAS'
'S'.
perform bdc_field using 'P1001-SOBID'
record-sobid."'50000288'.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark."'50000287'.
*perform bdc_transaction using 'PO13'.
CALL TRANSACTION 'PO13' USING I_BDCDATA MODE P_MODE.
CLEAR I_BDCDATA[].
endloop.
ENDFORM. " BDC
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR I_BDCDATA.
I_BDCDATA-PROGRAM = PROGRAM.
I_BDCDATA-DYNPRO = DYNPRO.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
ENDFORM. "bdc_dynpro
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = FNAM.
I_BDCDATA-FVAL = FVAL.
APPEND I_BDCDATA.
ENDFORM.
no standard page heading line-size 255.
DATA: I_BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE,
I_ERROR TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
PARAMETERS: P_FILE TYPE RLGRAP-FILENAME OBLIGATORY,
P_MODE(1) DEFAULT 'A'.
SELECTION-SCREEN : BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETER: PBROW_HD TYPE I default 1, PEROW_HD TYPE I, PBCOL_HD TYPE i default 1, PECOL_HD TYPE I default 2.
SELECTION-SCREEN : END OF BLOCK BLK1.
DATA: T_EXCEL LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA: BEGIN of record occurs 0,
SEARK(8),
SOBID(8),
end of record.
DATA: V_FILENAME LIKE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
START-OF-SELECTION.
PERFORM UPLOAD.
PERFORM BDC.
*&---------------------------------------------------------------------*
*& Form UPLOAD
*----------------------------------------------------------------------*
FORM UPLOAD .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = PBCOL_HD
I_BEGIN_ROW = PBROW_HD
I_END_COL = PECOL_HD
I_END_ROW = PEROW_HD
TABLES
INTERN = T_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
LOOP AT T_EXCEL.
CASE T_EXCEL-COL.
WHEN 1. MOVE T_EXCEL-VALUE TO RECORD-SEARK.
WHEN 2. MOVE T_EXCEL-VALUE TO RECORD-SOBID.
ENDCASE.
AT END OF ROW.
APPEND RECORD.
CLEAR RECORD.
ENDAT.
ENDLOOP.
ENDFORM. " UPLOAD
*&---------------------------------------------------------------------*
*& Form BDC
*----------------------------------------------------------------------*
FORM BDC .
loop at record.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_CURSOR'
'PM0D1-SEARK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark. " '50000287'.
perform bdc_field using 'PM0D1-TIMR6'
'X'.
perform bdc_field using 'PPHDR-BEGDA'
'07.07.2010'.
perform bdc_field using 'PPHDR-ENDDA'
'31.12.9999'.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_OKCODE'
'=INSE'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark."'50000287'.
perform bdc_field using 'BDC_CURSOR'
'PPHDR-BEGDA'.
perform bdc_field using 'PM0D1-TIMR6'
'X'.
perform bdc_field using 'PPHDR-BEGDA'
'01.07.2010'.
perform bdc_field using 'PPHDR-ENDDA'
'31.12.9999'.
perform bdc_field using 'MARKFELD(02)'
'X'.
perform bdc_dynpro using 'MP100100' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P1001-SOBID'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'P1001-BEGDA'
'01.07.2010'.
perform bdc_field using 'P1001-ENDDA'
'31.12.9999'.
perform bdc_field using 'P1001-RSIGN'
'a'.
perform bdc_field using 'P1001-RELAT'
'002'.
perform bdc_field using 'P1001-SCLAS'
'S'.
perform bdc_field using 'P1001-SOBID'
record-sobid."'50000288'.
perform bdc_dynpro using 'MP100100' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P1001-BEGDA'.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.
perform bdc_field using 'P1001-BEGDA'
'01.07.2010'.
perform bdc_field using 'P1001-ENDDA'
'31.12.9999'.
perform bdc_field using 'P1001-RSIGN'
'A'.
perform bdc_field using 'P1001-RELAT'
'002'.
perform bdc_field using 'P1001-SCLAS'
'S'.
perform bdc_field using 'P1001-SOBID'
record-sobid."'50000288'.
perform bdc_dynpro using 'SAPMH5A0' '5100'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_field using 'PPHDR-PLVAR'
'01'.
perform bdc_field using 'PM0D1-SEARK'
record-seark."'50000287'.
*perform bdc_transaction using 'PO13'.
CALL TRANSACTION 'PO13' USING I_BDCDATA MODE P_MODE.
CLEAR I_BDCDATA[].
endloop.
ENDFORM. " BDC
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR I_BDCDATA.
I_BDCDATA-PROGRAM = PROGRAM.
I_BDCDATA-DYNPRO = DYNPRO.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
ENDFORM. "bdc_dynpro
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = FNAM.
I_BDCDATA-FVAL = FVAL.
APPEND I_BDCDATA.
ENDFORM.
SAP ABAP - Sample Code - BDC For VK11 T-Code.
REPORT ZETM_BDC.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
KUNWE TYPE KUNWE,
EQART TYPE EQART,
J_3GLVART TYPE J_3GLVART,
KBETR(11),
KONWA TYPE KONWA,
KMEIN TYPE KMEIN,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
* STATIC = ' '
* MASK = ' '
CHANGING
FILE_NAME = P_FILE.
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
perform bdc_dynpro using 'SAPMV13A' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=ANTA'.
perform bdc_field using 'RV13A-KSCHL'
'MOVL'.
perform bdc_dynpro using 'SAPLV14A' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=WEIT'.
perform bdc_field using 'RV130-SELKZ(02)'
'X'.
perform bdc_dynpro using 'SAPMV13A' '1604'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform bdc_field using 'KOMG-KUNWE'
WA_DATA-KUNWE.
perform bdc_field using 'KOMG-EQART'
WA_DATA-EQART.
perform bdc_field using 'KOMG-J_3GLVART(01)'
WA_DATA-J_3GLVART.
perform bdc_field using 'KONP-KBETR(01)'
WA_DATA-KBETR.
perform bdc_field using 'KONP-KONWA(01)'
WA_DATA-KONWA.
perform bdc_field using 'KONP-KMEIN(01)'
WA_DATA-KMEIN.
CALL TRANSACTION 'VK11' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
KUNWE TYPE KUNWE,
EQART TYPE EQART,
J_3GLVART TYPE J_3GLVART,
KBETR(11),
KONWA TYPE KONWA,
KMEIN TYPE KMEIN,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
* STATIC = ' '
* MASK = ' '
CHANGING
FILE_NAME = P_FILE.
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
perform bdc_dynpro using 'SAPMV13A' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=ANTA'.
perform bdc_field using 'RV13A-KSCHL'
'MOVL'.
perform bdc_dynpro using 'SAPLV14A' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=WEIT'.
perform bdc_field using 'RV130-SELKZ(02)'
'X'.
perform bdc_dynpro using 'SAPMV13A' '1604'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform bdc_field using 'KOMG-KUNWE'
WA_DATA-KUNWE.
perform bdc_field using 'KOMG-EQART'
WA_DATA-EQART.
perform bdc_field using 'KOMG-J_3GLVART(01)'
WA_DATA-J_3GLVART.
perform bdc_field using 'KONP-KBETR(01)'
WA_DATA-KBETR.
perform bdc_field using 'KONP-KONWA(01)'
WA_DATA-KONWA.
perform bdc_field using 'KONP-KMEIN(01)'
WA_DATA-KMEIN.
CALL TRANSACTION 'VK11' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
SAP ABAP - BDC For J4GD In ETM Module - PM.
REPORT ZETM_BDC_J4GD.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
J_3GLVART TYPE J_3GLVART,
J_3GBLTYP1 TYPE J_3GBLTYP,
PLTYP1 TYPE PLTYP,
J_3GBLTYP2 TYPE J_3GBLTYP,
PLTYP2 TYPE PLTYP,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ANTA'.
PERFORM BDC_DYNPRO USING 'SAPLV14A' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WEIT'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '1504'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SICH'.
PERFORM BDC_FIELD USING 'J_3GKOMJ-EQUNR'
WA_DATA-EQUNR.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GLVART'
WA_DATA-J_3GLVART.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(01)'
WA_DATA-J_3GBLTYP1.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(02)'
WA_DATA-J_3GBLTYP2.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(01)'
WA_DATA-PLTYP1.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(02)'
WA_DATA-PLTYP2.
CALL TRANSACTION 'J4GD' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
J_3GLVART TYPE J_3GLVART,
J_3GBLTYP1 TYPE J_3GBLTYP,
PLTYP1 TYPE PLTYP,
J_3GBLTYP2 TYPE J_3GBLTYP,
PLTYP2 TYPE PLTYP,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ANTA'.
PERFORM BDC_DYNPRO USING 'SAPLV14A' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WEIT'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '1504'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SICH'.
PERFORM BDC_FIELD USING 'J_3GKOMJ-EQUNR'
WA_DATA-EQUNR.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GLVART'
WA_DATA-J_3GLVART.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(01)'
WA_DATA-J_3GBLTYP1.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(02)'
WA_DATA-J_3GBLTYP2.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(01)'
WA_DATA-PLTYP1.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(02)'
WA_DATA-PLTYP2.
CALL TRANSACTION 'J4GD' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
SAP ABAP - BDC For J4GD In ETM Module - PM.
REPORT ZETM_BDC_J4GD.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
J_3GLVART TYPE J_3GLVART,
J_3GBLTYP1 TYPE J_3GBLTYP,
PLTYP1 TYPE PLTYP,
J_3GBLTYP2 TYPE J_3GBLTYP,
PLTYP2 TYPE PLTYP,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ANTA'.
PERFORM BDC_DYNPRO USING 'SAPLV14A' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WEIT'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '1504'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SICH'.
PERFORM BDC_FIELD USING 'J_3GKOMJ-EQUNR'
WA_DATA-EQUNR.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GLVART'
WA_DATA-J_3GLVART.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(01)'
WA_DATA-J_3GBLTYP1.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(02)'
WA_DATA-J_3GBLTYP2.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(01)'
WA_DATA-PLTYP1.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(02)'
WA_DATA-PLTYP2.
CALL TRANSACTION 'J4GD' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
J_3GLVART TYPE J_3GLVART,
J_3GBLTYP1 TYPE J_3GBLTYP,
PLTYP1 TYPE PLTYP,
J_3GBLTYP2 TYPE J_3GBLTYP,
PLTYP2 TYPE PLTYP,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ANTA'.
PERFORM BDC_DYNPRO USING 'SAPLV14A' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WEIT'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GJ' '1504'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SICH'.
PERFORM BDC_FIELD USING 'J_3GKOMJ-EQUNR'
WA_DATA-EQUNR.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GLVART'
WA_DATA-J_3GLVART.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(01)'
WA_DATA-J_3GBLTYP1.
PERFORM BDC_FIELD USING 'J_3GKOMJ-J_3GBLTYP(02)'
WA_DATA-J_3GBLTYP2.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(01)'
WA_DATA-PLTYP1.
PERFORM BDC_FIELD USING 'J_3GPRLIST-PLTYP(02)'
WA_DATA-PLTYP2.
CALL TRANSACTION 'J4GD' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
SAP ABAP - BDC For J3GH In ETM Module - PM.
REPORT ZETM_BDC_J3GH.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
J_3GBELDAT(10),
J_3GEMPFAE TYPE J_3GEMPFAE,
EQUNR TYPE EQUNR,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA : WF_MESSAGE(100),
WF_CTR(3),
WF_CTR1(4),
WF_ITR(3),
WF_FNAM TYPE FNAM_____4.
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
AT NEW J_3GEMPFAE.
CLEAR : WF_CTR, WF_CTR1, WF_ITR.
WF_ITR = 10.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GBLART'
'C1'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0010'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GBELDAT'
WA_DATA-J_3GBELDAT.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GEMPFAE'
WA_DATA-J_3GEMPFAE.
ENDAT.
WF_CTR = WF_CTR + 1.
WF_CTR1 = WF_CTR1 + 10.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0010'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
CLEAR WF_FNAM.
CONCATENATE 'J_3GBELP-EQUNR(' WF_CTR ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-EQUNR.
IF WF_ITR = WF_CTR.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0010'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'VON_POS'
WF_CTR1.
CLEAR WF_CTR.
WF_CTR = 1.
ENDIF.
AT END OF J_3GEMPFAE.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0010'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SAVE'.
CALL TRANSACTION 'J3GH' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDAT.
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO .
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
J_3GBELDAT(10),
J_3GEMPFAE TYPE J_3GEMPFAE,
EQUNR TYPE EQUNR,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA : WF_MESSAGE(100),
WF_CTR(3),
WF_CTR1(4),
WF_ITR(3),
WF_FNAM TYPE FNAM_____4.
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
AT NEW J_3GEMPFAE.
CLEAR : WF_CTR, WF_CTR1, WF_ITR.
WF_ITR = 10.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GBLART'
'C1'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0010'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GBELDAT'
WA_DATA-J_3GBELDAT.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GEMPFAE'
WA_DATA-J_3GEMPFAE.
ENDAT.
WF_CTR = WF_CTR + 1.
WF_CTR1 = WF_CTR1 + 10.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0010'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
CLEAR WF_FNAM.
CONCATENATE 'J_3GBELP-EQUNR(' WF_CTR ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-EQUNR.
IF WF_ITR = WF_CTR.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0010'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'VON_POS'
WF_CTR1.
CLEAR WF_CTR.
WF_CTR = 1.
ENDIF.
AT END OF J_3GEMPFAE.
PERFORM BDC_DYNPRO USING 'SAPMJ3GF' '0010'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SAVE'.
CALL TRANSACTION 'J3GH' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDAT.
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO .
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
SAP ABAP - BDC For J3G$ In ETM Module - PM.
REPORT ZETM_BDC_J3G$.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
DATUM(10) TYPE C,
J_3GEMPFAE TYPE J_3GEMPFAE,
POSID TYPE PS_POSID,
EQUNR1 TYPE EQUNR,
J_3GLVART1 TYPE J_3GLVART,
J_3GMENGE1(8),
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_DATA1 TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA : WF_MESSAGE(100),
WF_CTR(3),
WF_CTR1(3),
WF_CTR2(3),
WF_FNAM TYPE FNAM_____4,
WF_COUNT(4),
WF_DATE TYPE DATUM,
WF_FLAG.
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE
.
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
CLEAR WA_DATA1.
WA_DATA1 = WA_DATA.
AT NEW J_3GEMPFAE.
CLEAR : WF_CTR, WF_CTR1, WF_CTR2, WF_COUNT, WF_DATE, WF_FLAG.
WF_DATE+0(1) = WA_DATA1-DATUM+6(1).
WF_DATE+1(1) = WA_DATA1-DATUM+7(1).
WF_DATE+2(1) = WA_DATA1-DATUM+8(1).
WF_DATE+3(1) = WA_DATA1-DATUM+9(1).
WF_DATE+4(1) = WA_DATA1-DATUM+3(1).
WF_DATE+5(1) = WA_DATA1-DATUM+4(1).
WF_DATE+6(1) = WA_DATA1-DATUM+0(1).
WF_DATE+7(1) = WA_DATA1-DATUM+1(1).
SELECT COUNT( * ) FROM J_3GBELP INTO WF_COUNT
WHERE J_3GBELNRI GE '4500000000'
AND J_3GBELNRI LE '4599999999'
AND J_3GUPOSNR EQ '01'
AND J_3GEMPFAE EQ WA_DATA1-J_3GEMPFAE
AND J_3GDATLAB EQ WF_DATE.
IF SY-SUBRC = 0.
WF_FLAG = 'X'.
ENDIF.
WF_CTR1 = 1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GBLART'
'P1'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'DATUM'
WA_DATA1-DATUM.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GEMPFAE'
WA_DATA1-J_3GEMPFAE.
IF NOT WA_DATA1-POSID IS INITIAL.
PERFORM BDC_DYNPRO USING 'SAPMSSY0' '0120'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'02/03'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=NSEL'.
PERFORM BDC_DYNPRO USING 'SAPLSDH4' '0200'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=GOON'.
PERFORM BDC_FIELD USING 'G_SELFLD_TAB-LOW(01)'
WA_DATA1-POSID.
PERFORM BDC_DYNPRO USING 'SAPMSSY0' '0120'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
ENDAT.
IF WF_FLAG = 'X'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'SCREEN_TOP_LINE'
WF_COUNT.
WF_CTR = 1.
CLEAR WF_FLAG.
ENDIF.
WF_CTR = WF_CTR + 1.
WF_CTR2 = WF_CTR.
IF WF_CTR > 13.
WF_CTR1 = WF_CTR1 + 1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'SCREEN_TOP_LINE'
WF_CTR1.
WF_CTR2 = '13'.
ENDIF.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-EQUNR(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-EQUNR1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-J_3GLVART(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GLVART1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_1(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_2(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_3(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_4(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_5(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_6(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_7(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
AT END OF J_3GEMPFAE.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SAVE'.
CALL TRANSACTION 'J3G$' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDAT.
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM
FVAL.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
DATUM(10) TYPE C,
J_3GEMPFAE TYPE J_3GEMPFAE,
POSID TYPE PS_POSID,
EQUNR1 TYPE EQUNR,
J_3GLVART1 TYPE J_3GLVART,
J_3GMENGE1(8),
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_DATA1 TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA : WF_MESSAGE(100),
WF_CTR(3),
WF_CTR1(3),
WF_CTR2(3),
WF_FNAM TYPE FNAM_____4,
WF_COUNT(4),
WF_DATE TYPE DATUM,
WF_FLAG.
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE
.
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
CLEAR WA_DATA1.
WA_DATA1 = WA_DATA.
AT NEW J_3GEMPFAE.
CLEAR : WF_CTR, WF_CTR1, WF_CTR2, WF_COUNT, WF_DATE, WF_FLAG.
WF_DATE+0(1) = WA_DATA1-DATUM+6(1).
WF_DATE+1(1) = WA_DATA1-DATUM+7(1).
WF_DATE+2(1) = WA_DATA1-DATUM+8(1).
WF_DATE+3(1) = WA_DATA1-DATUM+9(1).
WF_DATE+4(1) = WA_DATA1-DATUM+3(1).
WF_DATE+5(1) = WA_DATA1-DATUM+4(1).
WF_DATE+6(1) = WA_DATA1-DATUM+0(1).
WF_DATE+7(1) = WA_DATA1-DATUM+1(1).
SELECT COUNT( * ) FROM J_3GBELP INTO WF_COUNT
WHERE J_3GBELNRI GE '4500000000'
AND J_3GBELNRI LE '4599999999'
AND J_3GUPOSNR EQ '01'
AND J_3GEMPFAE EQ WA_DATA1-J_3GEMPFAE
AND J_3GDATLAB EQ WF_DATE.
IF SY-SUBRC = 0.
WF_FLAG = 'X'.
ENDIF.
WF_CTR1 = 1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GBLART'
'P1'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'DATUM'
WA_DATA1-DATUM.
PERFORM BDC_FIELD USING 'J_3GBELK-J_3GEMPFAE'
WA_DATA1-J_3GEMPFAE.
IF NOT WA_DATA1-POSID IS INITIAL.
PERFORM BDC_DYNPRO USING 'SAPMSSY0' '0120'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'02/03'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=NSEL'.
PERFORM BDC_DYNPRO USING 'SAPLSDH4' '0200'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=GOON'.
PERFORM BDC_FIELD USING 'G_SELFLD_TAB-LOW(01)'
WA_DATA1-POSID.
PERFORM BDC_DYNPRO USING 'SAPMSSY0' '0120'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
ENDAT.
IF WF_FLAG = 'X'.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'SCREEN_TOP_LINE'
WF_COUNT.
WF_CTR = 1.
CLEAR WF_FLAG.
ENDIF.
WF_CTR = WF_CTR + 1.
WF_CTR2 = WF_CTR.
IF WF_CTR > 13.
WF_CTR1 = WF_CTR1 + 1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'SCREEN_TOP_LINE'
WF_CTR1.
WF_CTR2 = '13'.
ENDIF.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-EQUNR(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-EQUNR1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-J_3GLVART(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GLVART1.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_1(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_2(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_3(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_4(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_5(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_6(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
CLEAR WF_FNAM.
CONCATENATE 'XMATRIX-MENGE_7(' WF_CTR2 ')' INTO WF_FNAM.
CONDENSE WF_FNAM NO-GAPS.
PERFORM BDC_FIELD USING WF_FNAM
WA_DATA-J_3GMENGE1.
AT END OF J_3GEMPFAE.
PERFORM BDC_DYNPRO USING 'SAPMJ3GI' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SAVE'.
CALL TRANSACTION 'J3G$' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDAT.
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM
FVAL.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
SAP ABAP - BDC For IE27 In ETM Module - PM.
REPORT ZETM_BDC_IE027.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
SHTXT TYPE KTX01,
FLEET_CAT TYPE FLEET_CAT,
J_3GEIGNER TYPE J_3GEIGNER,
J_3GPMAUFE TYPE J_3GPMAUFE,
J_3GVERWAL TYPE J_3GVERWAL,
J_3GPMAUFV TYPE J_3GPMAUFV,
J_3GPACHT TYPE J_3GPACHT,
MEINS TYPE MEINS,
J_3GKZMENG TYPE J_3GKZMENG,
J_3GEIFR TYPE J_3GEIFR,
J_3GEQART TYPE J_3GEQART,
J_3GKONDE TYPE KONDM,
/SAPCEM/DISPOGR TYPE /SAPCEM/DISPOGR,
J_3GZDEQUI TYPE J_3GZDEQUI,
KLART TYPE KLASSENART,
CLASS TYPE KLASSE_D,
MNAME TYPE ATBEZ,
MWERT TYPE ATWRT,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
***First Screen
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM63E-EQUNR'
WA_DATA-EQUNR.
***General
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\07'.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
' '.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
WA_DATA-SHTXT.
PERFORM BDC_FIELD USING 'FLEET-FLEET_CAT'
WA_DATA-FLEET_CAT.
***ETM Data
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=KL'.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
WA_DATA-J_3GEIGNER.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
WA_DATA-J_3GPMAUFE.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
WA_DATA-J_3GVERWAL.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
WA_DATA-J_3GPMAUFV.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
WA_DATA-J_3GPACHT.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
' '.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
WA_DATA-MEINS.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
WA_DATA-J_3GKZMENG.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
WA_DATA-J_3GEIFR.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
WA_DATA-J_3GEQART.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
WA_DATA-J_3GKONDE.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
' '.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
' '.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
'X'.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
' '.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
' '.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
WA_DATA-/SAPCEM/DISPOGR.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
WA_DATA-J_3GZDEQUI.
PERFORM BDC_DYNPRO USING 'SAPLCLCA' '0602'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
' '.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
WA_DATA-KLART.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
' '.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
WA_DATA-CLASS.
PERFORM BDC_DYNPRO USING 'SAPLCTMS' '0109'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
' '.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
WA_DATA-MNAME.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)'
' '.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)'
WA_DATA-MWERT.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENDE'.
PERFORM BDC_FIELD USING 'RMCLF-PAGPOS'
'1'.
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
CALL TRANSACTION 'IE02' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
SHTXT TYPE KTX01,
FLEET_CAT TYPE FLEET_CAT,
J_3GEIGNER TYPE J_3GEIGNER,
J_3GPMAUFE TYPE J_3GPMAUFE,
J_3GVERWAL TYPE J_3GVERWAL,
J_3GPMAUFV TYPE J_3GPMAUFV,
J_3GPACHT TYPE J_3GPACHT,
MEINS TYPE MEINS,
J_3GKZMENG TYPE J_3GKZMENG,
J_3GEIFR TYPE J_3GEIFR,
J_3GEQART TYPE J_3GEQART,
J_3GKONDE TYPE KONDM,
/SAPCEM/DISPOGR TYPE /SAPCEM/DISPOGR,
J_3GZDEQUI TYPE J_3GZDEQUI,
KLART TYPE KLASSENART,
CLASS TYPE KLASSE_D,
MNAME TYPE ATBEZ,
MWERT TYPE ATWRT,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE .
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA
.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
***First Screen
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM63E-EQUNR'
WA_DATA-EQUNR.
***General
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\07'.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
' '.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
WA_DATA-SHTXT.
PERFORM BDC_FIELD USING 'FLEET-FLEET_CAT'
WA_DATA-FLEET_CAT.
***ETM Data
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=KL'.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
WA_DATA-J_3GEIGNER.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
WA_DATA-J_3GPMAUFE.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
WA_DATA-J_3GVERWAL.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
WA_DATA-J_3GPMAUFV.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
WA_DATA-J_3GPACHT.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
' '.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
WA_DATA-MEINS.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
WA_DATA-J_3GKZMENG.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
WA_DATA-J_3GEIFR.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
WA_DATA-J_3GEQART.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
WA_DATA-J_3GKONDE.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
' '.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
' '.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
'X'.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
' '.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
' '.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
WA_DATA-/SAPCEM/DISPOGR.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
WA_DATA-J_3GZDEQUI.
PERFORM BDC_DYNPRO USING 'SAPLCLCA' '0602'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
' '.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
WA_DATA-KLART.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
' '.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
WA_DATA-CLASS.
PERFORM BDC_DYNPRO USING 'SAPLCTMS' '0109'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
' '.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
WA_DATA-MNAME.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)'
' '.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)'
WA_DATA-MWERT.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENDE'.
PERFORM BDC_FIELD USING 'RMCLF-PAGPOS'
'1'.
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
CALL TRANSACTION 'IE02' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
SAP ABAP - BDC For IE02 In ETM Module - PM.
REPORT ZETM_BDC_IE02.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
SHTXT TYPE KTX01,
* EQART TYPE EQART,
FLEET_CAT TYPE FLEET_CAT,
J_3GEIGNER TYPE J_3GEIGNER,
J_3GPMAUFE TYPE J_3GPMAUFE,
J_3GVERWAL TYPE J_3GVERWAL,
J_3GPMAUFV TYPE J_3GPMAUFV,
J_3GPACHT TYPE J_3GPACHT,
MEINS TYPE MEINS,
J_3GKZMENG TYPE J_3GKZMENG,
J_3GEIFR TYPE J_3GEIFR,
J_3GEQART TYPE J_3GEQART,
J_3GKONDE TYPE KONDM,
/SAPCEM/DISPOGR TYPE /SAPCEM/DISPOGR,
J_3GZDEQUI TYPE J_3GZDEQUI,
KLART TYPE KLASSENART,
CLASS TYPE KLASSE_D,
MNAME TYPE ATBEZ,
MWERT TYPE ATWRT,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE
.
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
***First Screen
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM63E-EQUNR'
WA_DATA-EQUNR.
***General
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\05'.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
' '.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
WA_DATA-SHTXT.
PERFORM BDC_FIELD USING 'FLEET-FLEET_CAT'
WA_DATA-FLEET_CAT.
***ETM Data
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=KL'.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
WA_DATA-J_3GEIGNER.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
WA_DATA-J_3GPMAUFE.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
WA_DATA-J_3GVERWAL.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
WA_DATA-J_3GPMAUFV.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
WA_DATA-J_3GPACHT.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
' '.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
WA_DATA-MEINS.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
WA_DATA-J_3GKZMENG.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
WA_DATA-J_3GEIFR.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
WA_DATA-J_3GEQART.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
WA_DATA-J_3GKONDE.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
' '.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
' '.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
'X'.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
' '.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
' '.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
WA_DATA-/SAPCEM/DISPOGR.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
WA_DATA-J_3GZDEQUI.
PERFORM BDC_DYNPRO USING 'SAPLCLCA' '0602'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
' '.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
WA_DATA-KLART.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
' '.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
WA_DATA-CLASS.
PERFORM BDC_DYNPRO USING 'SAPLCTMS' '0109'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
' '.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
WA_DATA-MNAME.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)'
' '.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)'
WA_DATA-MWERT.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENDE'.
PERFORM BDC_FIELD USING 'RMCLF-PAGPOS'
'1'.
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
CALL TRANSACTION 'IE02' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
SHTXT TYPE KTX01,
* EQART TYPE EQART,
FLEET_CAT TYPE FLEET_CAT,
J_3GEIGNER TYPE J_3GEIGNER,
J_3GPMAUFE TYPE J_3GPMAUFE,
J_3GVERWAL TYPE J_3GVERWAL,
J_3GPMAUFV TYPE J_3GPMAUFV,
J_3GPACHT TYPE J_3GPACHT,
MEINS TYPE MEINS,
J_3GKZMENG TYPE J_3GKZMENG,
J_3GEIFR TYPE J_3GEIFR,
J_3GEQART TYPE J_3GEQART,
J_3GKONDE TYPE KONDM,
/SAPCEM/DISPOGR TYPE /SAPCEM/DISPOGR,
J_3GZDEQUI TYPE J_3GZDEQUI,
KLART TYPE KLASSENART,
CLASS TYPE KLASSE_D,
MNAME TYPE ATBEZ,
MWERT TYPE ATWRT,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE
.
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA.
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
***First Screen
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM63E-EQUNR'
WA_DATA-EQUNR.
***General
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\05'.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
' '.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
WA_DATA-SHTXT.
PERFORM BDC_FIELD USING 'FLEET-FLEET_CAT'
WA_DATA-FLEET_CAT.
***ETM Data
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=KL'.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
WA_DATA-J_3GEIGNER.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
WA_DATA-J_3GPMAUFE.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
WA_DATA-J_3GVERWAL.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
WA_DATA-J_3GPMAUFV.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
' '.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
WA_DATA-J_3GPACHT.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
' '.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
WA_DATA-MEINS.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
WA_DATA-J_3GKZMENG.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
WA_DATA-J_3GEIFR.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
WA_DATA-J_3GEQART.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
WA_DATA-J_3GKONDE.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
' '.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
' '.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
'X'.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
' '.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
' '.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
WA_DATA-/SAPCEM/DISPOGR.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
' '.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
WA_DATA-J_3GZDEQUI.
PERFORM BDC_DYNPRO USING 'SAPLCLCA' '0602'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
' '.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
WA_DATA-KLART.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
' '.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
WA_DATA-CLASS.
PERFORM BDC_DYNPRO USING 'SAPLCTMS' '0109'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
' '.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
WA_DATA-MNAME.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)'
' '.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)'
WA_DATA-MWERT.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENDE'.
PERFORM BDC_FIELD USING 'RMCLF-PAGPOS'
'1'.
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
CALL TRANSACTION 'IE02' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
SAP ABAP - BDC For IE01 T-Code In ETM Module - PM
REPORT ZETM_BDC_IE01.
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
EQTYP TYPE EQTYP,
SHTXT TYPE KTX01,
EQART TYPE EQART,
BRGEW(13),
GEWEI TYPE WEIGHT_UNIT,
GROES TYPE GROES,
INVNR TYPE INVNR,
INBDT(10),
ANSWT(13),
WAERS TYPE WAERS,
ANSDT(10),
HERST TYPE HERST,
HERLD TYPE HERLD,
TYPBZ TYPE TYPBZ,
BAUJJ TYPE BAUJJ,
BAUMM TYPE BAUMM,
MAPAR TYPE MAPAR,
SERGE TYPE SERGE,
SWERK TYPE SWERK,
STORT TYPE PMLOC,
MSGRP TYPE RAUMNR,
BEBER TYPE BEBER,
ARBPL TYPE ARBPL,
ABCKZ TYPE ABCKZ,
EQFNR TYPE EQFNR,
ANLNR TYPE ANLN1,
KOSTL TYPE KOSTL,
GEWRK TYPE GEWRK,
RBNR TYPE RBNR,
TIDNR TYPE TIDNR,
J_3GEIGNER TYPE J_3GEIGNER,
J_3GPMAUFE TYPE J_3GPMAUFE,
J_3GVERWAL TYPE J_3GVERWAL,
J_3GPMAUFV TYPE J_3GPMAUFV,
J_3GPACHT TYPE J_3GPACHT,
MEINS TYPE MEINS,
J_3GKZMENG TYPE J_3GKZMENG,
J_3GEIFR TYPE J_3GEIFR,
J_3GEQART TYPE J_3GEQART,
J_3GKONDE TYPE KONDM,
/SAPCEM/DISPOGR TYPE /SAPCEM/DISPOGR,
J_3GZDEQUI TYPE J_3GZDEQUI,
KLART TYPE KLASSENART,
CLASS TYPE KLASSE_D,
MNAME TYPE ATBEZ,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE.
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA .
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
***First Screen
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM63E-EQUNR'
WA_DATA-EQUNR.
PERFORM BDC_FIELD USING 'RM63E-DATSL'
'01.01.2009'.
PERFORM BDC_FIELD USING 'RM63E-EQTYP'
WA_DATA-EQTYP.
***General
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\02'.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
WA_DATA-SHTXT.
PERFORM BDC_FIELD USING 'ITOB-EQART'
WA_DATA-EQART.
PERFORM BDC_FIELD USING 'ITOB-BRGEW'
WA_DATA-BRGEW.
PERFORM BDC_FIELD USING 'ITOB-GEWEI'
WA_DATA-GEWEI.
PERFORM BDC_FIELD USING 'ITOB-GROES'
WA_DATA-GROES.
PERFORM BDC_FIELD USING 'ITOB-INVNR'
WA_DATA-INVNR.
PERFORM BDC_FIELD USING 'ITOB-INBDT'
WA_DATA-INBDT.
PERFORM BDC_FIELD USING 'ITOB-ANSWT'
WA_DATA-ANSWT.
PERFORM BDC_FIELD USING 'ITOB-WAERS'
WA_DATA-WAERS.
PERFORM BDC_FIELD USING 'ITOB-ANSDT'
WA_DATA-ANSDT.
PERFORM BDC_FIELD USING 'ITOB-HERST'
WA_DATA-HERST.
PERFORM BDC_FIELD USING 'ITOB-HERLD'
WA_DATA-HERLD.
PERFORM BDC_FIELD USING 'ITOB-TYPBZ'
WA_DATA-TYPBZ.
PERFORM BDC_FIELD USING 'ITOB-BAUJJ'
WA_DATA-BAUJJ.
PERFORM BDC_FIELD USING 'ITOB-BAUMM'
WA_DATA-BAUMM.
PERFORM BDC_FIELD USING 'ITOB-MAPAR'
WA_DATA-MAPAR.
PERFORM BDC_FIELD USING 'ITOB-SERGE'
WA_DATA-SERGE.
***Location
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\03'.
PERFORM BDC_FIELD USING 'ITOB-SWERK'
WA_DATA-SWERK.
PERFORM BDC_FIELD USING 'ITOB-STORT'
WA_DATA-STORT.
PERFORM BDC_FIELD USING 'ITOB-MSGRP'
WA_DATA-MSGRP.
PERFORM BDC_FIELD USING 'ITOB-BEBER'
WA_DATA-BEBER.
PERFORM BDC_FIELD USING 'ITOBATTR-ARBPL'
WA_DATA-ARBPL.
PERFORM BDC_FIELD USING 'ITOB-ABCKZ'
WA_DATA-ABCKZ.
PERFORM BDC_FIELD USING 'ITOB-EQFNR'
WA_DATA-EQFNR.
***Organization
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\04'.
PERFORM BDC_FIELD USING 'ITOB-ANLNR'
WA_DATA-ANLNR.
PERFORM BDC_FIELD USING 'ITOB-KOSTL'
WA_DATA-KOSTL.
PERFORM BDC_FIELD USING 'ITOBATTR-GEWRK'
WA_DATA-GEWRK.
PERFORM BDC_FIELD USING 'ITOBATTR-WERGW'
WA_DATA-SWERK.
PERFORM BDC_FIELD USING 'ITOB-RBNR'
WA_DATA-RBNR.
***Structure
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\05'.
PERFORM BDC_FIELD USING 'ITOB-TIDNR'
WA_DATA-TIDNR.
***ETM Data
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=KL'.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
WA_DATA-J_3GEIGNER.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
WA_DATA-J_3GPMAUFE.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
WA_DATA-J_3GVERWAL.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
WA_DATA-J_3GPMAUFV.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
WA_DATA-J_3GPACHT.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
WA_DATA-MEINS.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
WA_DATA-J_3GKZMENG.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
WA_DATA-J_3GEIFR.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
WA_DATA-J_3GEQART.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
WA_DATA-J_3GKONDE.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
'X'.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
WA_DATA-/SAPCEM/DISPOGR.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
WA_DATA-J_3GZDEQUI.
PERFORM BDC_DYNPRO USING 'SAPLCLCA' '0602'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
WA_DATA-KLART.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
WA_DATA-CLASS.
PERFORM BDC_DYNPRO USING 'SAPLCTMS' '0109'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
WA_DATA-MNAME.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENDE'.
PERFORM BDC_FIELD USING 'RMCLF-PAGPOS'
'1'.
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
CALL TRANSACTION 'IE01' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
************************************************************************
*TYPE-POOLS *
************************************************************************
TYPE-POOLS TRUXS.
************************************************************************
*TYPE DECLARATION *
************************************************************************
TYPES : BEGIN OF TYPE_BDCDATA,
PROGRAM TYPE BDC_PROG,
DYNPRO TYPE BDC_DYNR,
DYNBEGIN TYPE BDC_START,
FNAM TYPE FNAM_____4,
FVAL TYPE BDC_FVAL,
END OF TYPE_BDCDATA,
BEGIN OF TYPE_DATA,
EQUNR TYPE EQUNR,
EQTYP TYPE EQTYP,
SHTXT TYPE KTX01,
EQART TYPE EQART,
BRGEW(13),
GEWEI TYPE WEIGHT_UNIT,
GROES TYPE GROES,
INVNR TYPE INVNR,
INBDT(10),
ANSWT(13),
WAERS TYPE WAERS,
ANSDT(10),
HERST TYPE HERST,
HERLD TYPE HERLD,
TYPBZ TYPE TYPBZ,
BAUJJ TYPE BAUJJ,
BAUMM TYPE BAUMM,
MAPAR TYPE MAPAR,
SERGE TYPE SERGE,
SWERK TYPE SWERK,
STORT TYPE PMLOC,
MSGRP TYPE RAUMNR,
BEBER TYPE BEBER,
ARBPL TYPE ARBPL,
ABCKZ TYPE ABCKZ,
EQFNR TYPE EQFNR,
ANLNR TYPE ANLN1,
KOSTL TYPE KOSTL,
GEWRK TYPE GEWRK,
RBNR TYPE RBNR,
TIDNR TYPE TIDNR,
J_3GEIGNER TYPE J_3GEIGNER,
J_3GPMAUFE TYPE J_3GPMAUFE,
J_3GVERWAL TYPE J_3GVERWAL,
J_3GPMAUFV TYPE J_3GPMAUFV,
J_3GPACHT TYPE J_3GPACHT,
MEINS TYPE MEINS,
J_3GKZMENG TYPE J_3GKZMENG,
J_3GEIFR TYPE J_3GEIFR,
J_3GEQART TYPE J_3GEQART,
J_3GKONDE TYPE KONDM,
/SAPCEM/DISPOGR TYPE /SAPCEM/DISPOGR,
J_3GZDEQUI TYPE J_3GZDEQUI,
KLART TYPE KLASSENART,
CLASS TYPE KLASSE_D,
MNAME TYPE ATBEZ,
END OF TYPE_DATA.
************************************************************************
*WORK AREA DECLARATION *
************************************************************************
DATA : WA_BDCDATA TYPE TYPE_BDCDATA,
WA_DATA TYPE TYPE_DATA,
WA_MESSTAB TYPE BDCMSGCOLL,
WA_RAW TYPE TRUXS_T_TEXT_DATA.
************************************************************************
*INTERNAL TABLE DECLARATION *
************************************************************************
DATA : I_BDCDATA TYPE STANDARD TABLE OF TYPE_BDCDATA,
I_DATA TYPE STANDARD TABLE OF TYPE_DATA,
I_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
************************************************************************
*DATA DECLARATION *
************************************************************************
DATA WF_MESSAGE(100).
************************************************************************
*SELECTION-SCREEN DECLARATION *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY,
P_MODE DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK A1.
************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST DECLARATION *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'P_FILE'
CHANGING
FILE_NAME = P_FILE.
REFRESH I_DATA[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = WA_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = I_DATA .
************************************************************************
*START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
LOOP AT I_DATA INTO WA_DATA.
***First Screen
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM63E-EQUNR'
WA_DATA-EQUNR.
PERFORM BDC_FIELD USING 'RM63E-DATSL'
'01.01.2009'.
PERFORM BDC_FIELD USING 'RM63E-EQTYP'
WA_DATA-EQTYP.
***General
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\02'.
PERFORM BDC_FIELD USING 'ITOB-SHTXT'
WA_DATA-SHTXT.
PERFORM BDC_FIELD USING 'ITOB-EQART'
WA_DATA-EQART.
PERFORM BDC_FIELD USING 'ITOB-BRGEW'
WA_DATA-BRGEW.
PERFORM BDC_FIELD USING 'ITOB-GEWEI'
WA_DATA-GEWEI.
PERFORM BDC_FIELD USING 'ITOB-GROES'
WA_DATA-GROES.
PERFORM BDC_FIELD USING 'ITOB-INVNR'
WA_DATA-INVNR.
PERFORM BDC_FIELD USING 'ITOB-INBDT'
WA_DATA-INBDT.
PERFORM BDC_FIELD USING 'ITOB-ANSWT'
WA_DATA-ANSWT.
PERFORM BDC_FIELD USING 'ITOB-WAERS'
WA_DATA-WAERS.
PERFORM BDC_FIELD USING 'ITOB-ANSDT'
WA_DATA-ANSDT.
PERFORM BDC_FIELD USING 'ITOB-HERST'
WA_DATA-HERST.
PERFORM BDC_FIELD USING 'ITOB-HERLD'
WA_DATA-HERLD.
PERFORM BDC_FIELD USING 'ITOB-TYPBZ'
WA_DATA-TYPBZ.
PERFORM BDC_FIELD USING 'ITOB-BAUJJ'
WA_DATA-BAUJJ.
PERFORM BDC_FIELD USING 'ITOB-BAUMM'
WA_DATA-BAUMM.
PERFORM BDC_FIELD USING 'ITOB-MAPAR'
WA_DATA-MAPAR.
PERFORM BDC_FIELD USING 'ITOB-SERGE'
WA_DATA-SERGE.
***Location
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\03'.
PERFORM BDC_FIELD USING 'ITOB-SWERK'
WA_DATA-SWERK.
PERFORM BDC_FIELD USING 'ITOB-STORT'
WA_DATA-STORT.
PERFORM BDC_FIELD USING 'ITOB-MSGRP'
WA_DATA-MSGRP.
PERFORM BDC_FIELD USING 'ITOB-BEBER'
WA_DATA-BEBER.
PERFORM BDC_FIELD USING 'ITOBATTR-ARBPL'
WA_DATA-ARBPL.
PERFORM BDC_FIELD USING 'ITOB-ABCKZ'
WA_DATA-ABCKZ.
PERFORM BDC_FIELD USING 'ITOB-EQFNR'
WA_DATA-EQFNR.
***Organization
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\04'.
PERFORM BDC_FIELD USING 'ITOB-ANLNR'
WA_DATA-ANLNR.
PERFORM BDC_FIELD USING 'ITOB-KOSTL'
WA_DATA-KOSTL.
PERFORM BDC_FIELD USING 'ITOBATTR-GEWRK'
WA_DATA-GEWRK.
PERFORM BDC_FIELD USING 'ITOBATTR-WERGW'
WA_DATA-SWERK.
PERFORM BDC_FIELD USING 'ITOB-RBNR'
WA_DATA-RBNR.
***Structure
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=T\05'.
PERFORM BDC_FIELD USING 'ITOB-TIDNR'
WA_DATA-TIDNR.
***ETM Data
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=KL'.
PERFORM BDC_FIELD USING 'EQUZ-J_3GEIGNER'
WA_DATA-J_3GEIGNER.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFE'
WA_DATA-J_3GPMAUFE.
PERFORM BDC_FIELD USING 'EQUZ-J_3GVERWAL'
WA_DATA-J_3GVERWAL.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPMAUFV'
WA_DATA-J_3GPMAUFV.
PERFORM BDC_FIELD USING 'EQUZ-J_3GPACHT'
WA_DATA-J_3GPACHT.
PERFORM BDC_FIELD USING 'EQUI-MEINS'
WA_DATA-MEINS.
PERFORM BDC_FIELD USING 'EQUI-J_3GKZMENG'
WA_DATA-J_3GKZMENG.
PERFORM BDC_FIELD USING 'EQUI-J_3GEIFR'
WA_DATA-J_3GEIFR.
PERFORM BDC_FIELD USING 'EQUI-J_3GEQART'
WA_DATA-J_3GEQART.
PERFORM BDC_FIELD USING 'EQUI-J_3GKONDE'
WA_DATA-J_3GKONDE.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_VB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/ABRECHLG'
'X'.
PERFORM BDC_FIELD USING 'H_ZULBLTYP_LB'
'X'.
PERFORM BDC_FIELD USING 'EQUI-/SAPCEM/DISPOGR'
WA_DATA-/SAPCEM/DISPOGR.
PERFORM BDC_FIELD USING 'EQUI-J_3GZDEQUI'
WA_DATA-J_3GZDEQUI.
PERFORM BDC_DYNPRO USING 'SAPLCLCA' '0602'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'RMCLF-KLART'
WA_DATA-KLART.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMCLF-CLASS(01)'
WA_DATA-CLASS.
PERFORM BDC_DYNPRO USING 'SAPLCTMS' '0109'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)'
WA_DATA-MNAME.
PERFORM BDC_DYNPRO USING 'SAPLCLFM' '0500'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENDE'.
PERFORM BDC_FIELD USING 'RMCLF-PAGPOS'
'1'.
PERFORM BDC_DYNPRO USING 'SAPMIEQ0' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
CALL TRANSACTION 'IE01' USING I_BDCDATA MODE P_MODE UPDATE 'A' MESSAGES INTO I_MESSTAB.
REFRESH I_BDCDATA[].
ENDLOOP.
************************************************************************
*START-OF-SELECTION *
************************************************************************
END-OF-SELECTION.
LOOP AT I_MESSTAB INTO WA_MESSTAB.
CLEAR WF_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_MESSTAB-MSGNR
V1 = WA_MESSTAB-MSGV1
V2 = WA_MESSTAB-MSGV2
V3 = WA_MESSTAB-MSGV3
V4 = WA_MESSTAB-MSGV4
IMPORTING
MSG = WF_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
WRITE / WF_MESSAGE .
ENDLOOP.
ULINE.
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM TYPE ANY
FVAL TYPE ANY.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM. " BDC_DYNPRO
SAP ABAP - Update Roles For The Users.
REPORT zrole_update.
TABLES: agr_define.
TYPES: BEGIN OF ty_upload,
user TYPE char30,
role TYPE char30,
END OF ty_upload.
DATA: username LIKE bapibname-bapibname,
activitygroups TYPE TABLE OF bapiagr WITH HEADER LINE,
return TYPE TABLE OF bapiret2 WITH HEADER LINE,
uname LIKE bapibname-bapibname,
roles TYPE TABLE OF bapiagr WITH HEADER LINE,
ret TYPE TABLE OF bapiret2 WITH HEADER LINE,
ret2 LIKE bapireturn1,
itab TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE,
it_upload TYPE TABLE OF ty_upload WITH HEADER LINE.
SELECT-OPTIONS: s_name FOR agr_define-agr_name.
PARAMETERS: p_file TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
START-OF-SELECTION.
PERFORM get_file_data.
END-OF-SELECTION.
PERFORM get_user_roles.
PERFORM create_roles.
*&---------------------------------------------------------------------*
*& Form GET_FILE_DATA
*----------------------------------------------------------------------*
FORM get_file_data .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = 1
i_end_col = 10000
i_end_row = 65535
TABLES
intern = itab.
DELETE itab WHERE row = 1.
LOOP AT itab .
CASE: itab-col.
WHEN '0001'.
it_upload-user = itab-value.
WHEN '0002'.
it_upload-role = itab-value.
ENDCASE.
AT END OF row.
APPEND it_upload.
ENDAT.
ENDLOOP.
ENDFORM. " GET_FILE_DATA
*&---------------------------------------------------------------------*
*& Form GET_USER_ROLES
*----------------------------------------------------------------------*
FORM get_user_roles .
LOOP AT it_upload.
username = uname = it_upload-user .
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = uname
TABLES
activitygroups = roles
return = ret.
LOOP AT roles.
CLEAR : roles-to_dat.
roles-to_dat = '99991231'.
MOVE roles TO activitygroups .
APPEND activitygroups.
ENDLOOP.
CALL FUNCTION 'BAPI_USER_ACTGROUPS_ASSIGN'
EXPORTING
username = username
TABLES
activitygroups = activitygroups
return = return.
IF return IS INITIAL.
WRITE:/ 'Roles for the user is successful with end dates', username.
ELSE.
WRITE:/ 'Roles for the user is unsuccessful with end dates', username.
ENDIF.
ENDLOOP.
ENDFORM. " GET_USER_ROLES
*&---------------------------------------------------------------------*
*& Form CREATE_ROLES
*----------------------------------------------------------------------*
FORM create_roles .
DATA : v_user TYPE xubname,
it_roles TYPE TABLE OF bapiagr WITH HEADER LINE,
wa_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
TYPES: BEGIN OF ty_texts,
agr_name TYPE agr_texts-agr_name,
text TYPE agr_texts-text,
END OF ty_texts.
DATA: it_text TYPE TABLE OF ty_texts WITH HEADER LINE.
SELECT agr_name
text
FROM agr_texts
INTO TABLE it_text
FOR ALL ENTRIES IN it_upload
WHERE agr_name = it_upload-role.
LOOP AT it_upload.
it_roles-agr_name = it_upload-role.
it_roles-from_dat = sy-datum.
it_roles-from_dat = '99991231'.
READ TABLE it_text WITH KEY agr_name = it_upload-role.
IF sy-subrc = 0.
it_roles-agr_text = it_text-text.
ENDIF.
APPEND it_roles.
CLEAR it_roles.
AT END OF user.
v_user = it_upload-user.
CALL FUNCTION '/SDF/UPDATE_AUTH_ROLES'
EXPORTING
username = v_user
TABLES
roles = it_roles
return = wa_return.
ENDAT.
ENDLOOP.
ENDFORM. " CREATE_ROLES
TABLES: agr_define.
TYPES: BEGIN OF ty_upload,
user TYPE char30,
role TYPE char30,
END OF ty_upload.
DATA: username LIKE bapibname-bapibname,
activitygroups TYPE TABLE OF bapiagr WITH HEADER LINE,
return TYPE TABLE OF bapiret2 WITH HEADER LINE,
uname LIKE bapibname-bapibname,
roles TYPE TABLE OF bapiagr WITH HEADER LINE,
ret TYPE TABLE OF bapiret2 WITH HEADER LINE,
ret2 LIKE bapireturn1,
itab TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE,
it_upload TYPE TABLE OF ty_upload WITH HEADER LINE.
SELECT-OPTIONS: s_name FOR agr_define-agr_name.
PARAMETERS: p_file TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
START-OF-SELECTION.
PERFORM get_file_data.
END-OF-SELECTION.
PERFORM get_user_roles.
PERFORM create_roles.
*&---------------------------------------------------------------------*
*& Form GET_FILE_DATA
*----------------------------------------------------------------------*
FORM get_file_data .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = 1
i_end_col = 10000
i_end_row = 65535
TABLES
intern = itab.
DELETE itab WHERE row = 1.
LOOP AT itab .
CASE: itab-col.
WHEN '0001'.
it_upload-user = itab-value.
WHEN '0002'.
it_upload-role = itab-value.
ENDCASE.
AT END OF row.
APPEND it_upload.
ENDAT.
ENDLOOP.
ENDFORM. " GET_FILE_DATA
*&---------------------------------------------------------------------*
*& Form GET_USER_ROLES
*----------------------------------------------------------------------*
FORM get_user_roles .
LOOP AT it_upload.
username = uname = it_upload-user .
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = uname
TABLES
activitygroups = roles
return = ret.
LOOP AT roles.
CLEAR : roles-to_dat.
roles-to_dat = '99991231'.
MOVE roles TO activitygroups .
APPEND activitygroups.
ENDLOOP.
CALL FUNCTION 'BAPI_USER_ACTGROUPS_ASSIGN'
EXPORTING
username = username
TABLES
activitygroups = activitygroups
return = return.
IF return IS INITIAL.
WRITE:/ 'Roles for the user is successful with end dates', username.
ELSE.
WRITE:/ 'Roles for the user is unsuccessful with end dates', username.
ENDIF.
ENDLOOP.
ENDFORM. " GET_USER_ROLES
*&---------------------------------------------------------------------*
*& Form CREATE_ROLES
*----------------------------------------------------------------------*
FORM create_roles .
DATA : v_user TYPE xubname,
it_roles TYPE TABLE OF bapiagr WITH HEADER LINE,
wa_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
TYPES: BEGIN OF ty_texts,
agr_name TYPE agr_texts-agr_name,
text TYPE agr_texts-text,
END OF ty_texts.
DATA: it_text TYPE TABLE OF ty_texts WITH HEADER LINE.
SELECT agr_name
text
FROM agr_texts
INTO TABLE it_text
FOR ALL ENTRIES IN it_upload
WHERE agr_name = it_upload-role.
LOOP AT it_upload.
it_roles-agr_name = it_upload-role.
it_roles-from_dat = sy-datum.
it_roles-from_dat = '99991231'.
READ TABLE it_text WITH KEY agr_name = it_upload-role.
IF sy-subrc = 0.
it_roles-agr_text = it_text-text.
ENDIF.
APPEND it_roles.
CLEAR it_roles.
AT END OF user.
v_user = it_upload-user.
CALL FUNCTION '/SDF/UPDATE_AUTH_ROLES'
EXPORTING
username = v_user
TABLES
roles = it_roles
return = wa_return.
ENDAT.
ENDLOOP.
ENDFORM. " CREATE_ROLES
SAP ABAP - BDC for KS01.
report ZCO_BDC_KS01
no standard page heading line-size 255.
include bdcrecx1.
TYPES: begin of T_IT_record,
* data element: KOKRS
KOKRS(004),
* data element: KOSTL
KOSTL(010),
* data element: DATAB
DATAB_ANFO(010),
* data element: DATBI
DATBI_ANFO(010),
* data element: KTEXT
KTEXT(020),
* data element: KLTXT
LTEXT(040),
* data element: VERAK
VERAK(020),
* data element: ABTEI
ABTEI(012),
* data element: KOSAR
KOSAR(001),
* data element: KHINR
KHINR(012),
* data element: PRCTR
PRCTR(010),
end of T_IT_record.
*&---------------------------------------------------------------------*
*& Internal Table
*&---------------------------------------------------------------------*
DATA: GIT_record TYPE STANDARD TABLE OF T_IT_record INITIAL SIZE 0.
*&---------------------------------------------------------------------*
*& Work Area
*&---------------------------------------------------------------------*
DATA: record TYPE T_IT_record.
*&---------------------------------------------------------------------*
*& Selection Criteria
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME .
PARAMETERS: P_FNAME TYPE LOCALFILE OBLIGATORY . " File Name
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN SKIP 1.
*----------------------------------------------------------------------*
* Variable
*----------------------------------------------------------------------*
DATA: V_FILENAME TYPE LOCALFILE. " File Name
*&---------------------------------------------------------------------*
*& At Selection Screen on value-request
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
*Get the browser to select the file
PERFORM SUB_GET_FILE.
start-of-selection.
* Move the value from selection to global variable
V_FILENAME = P_FNAME.
* Load the file into the Internal table
PERFORM SUB_UPLOAD_DATA.
perform open_group.
LOOP AT GIT_RECORD INTO RECORD.
perform bdc_dynpro using 'SAPLKMA1' '0200'.
perform bdc_field using 'BDC_CURSOR'
'CSKSZ-DATAB_ANFO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'CSKSZ-KOKRS'
record-KOKRS.
perform bdc_field using 'CSKSZ-KOSTL'
record-KOSTL.
perform bdc_field using 'CSKSZ-DATAB_ANFO'
record-DATAB_ANFO.
perform bdc_field using 'CSKSZ-DATBI_ANFO'
record-DATBI_ANFO.
perform bdc_dynpro using 'SAPLKMA1' '0299'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'CSKSZ-PRCTR'.
perform bdc_field using 'CSKSZ-KTEXT'
record-KTEXT.
perform bdc_field using 'CSKSZ-LTEXT'
record-LTEXT.
perform bdc_field using 'CSKSZ-VERAK'
record-VERAK.
perform bdc_field using 'CSKSZ-ABTEI'
record-ABTEI.
perform bdc_field using 'CSKSZ-KOSAR'
record-KOSAR.
perform bdc_field using 'CSKSZ-KHINR'
record-KHINR.
perform bdc_field using 'CSKSZ-PRCTR'
record-PRCTR.
perform bdc_transaction using 'KS01'.
ENDLOOP.
perform close_group.
*&---------------------------------------------------------------------*
*& Form SUB_GET_FILE
*----------------------------------------------------------------------*
FORM SUB_GET_FILE .
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FNAME.
ENDFORM. " SUB_GET_FILE
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA .
DATA: LWA_INTERN TYPE ALSMEX_TABLINE,
LIT_INTERN TYPE STANDARD TABLE OF ALSMEX_TABLINE INITIAL SIZE 0.
DATA LEN TYPE I.
DATA L_ROW TYPE KCD_EX_ROW_N. " Row
DATA int TYPE I. " Row
DATA CHECK.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = V_FILENAME
I_BEGIN_COL = 1 "P_FRMCOL
I_BEGIN_ROW = 5 "P_FRMLIN
I_END_COL = 11 "P_TOCOL
I_END_ROW = 65536 "P_TOLINE
TABLES
INTERN = LIT_INTERN
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0 .
MESSAGE TEXT-003 TYPE 'I'.
" Error in uploading the file from presentation server
LEAVE LIST-PROCESSING.
ELSE.
L_ROW = 1.
LOOP AT LIT_INTERN INTO LWA_INTERN.
IF L_ROW = LWA_INTERN-ROW.
IF LWA_INTERN-COL = 1.
record-KOKRS = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 2.
record-KOSTL = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 3.
record-DATAB_ANFO = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 4.
record-DATBI_ANFO = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 5.
LEN = STRLEN( LWA_INTERN-VALUE ).
IF LEN > 20.
MESSAGE I001(ZCO_LEN).
CLEAR GIT_record.
EXIT.
ELSE.
record-KTEXT = LWA_INTERN-VALUE.
ENDIF.
ELSEIF LWA_INTERN-COL = 6.
LEN = STRLEN( LWA_INTERN-VALUE ).
IF LEN > 40.
MESSAGE I002(ZCO_LEN).
CLEAR GIT_record.
EXIT.
ELSE.
record-LTEXT = LWA_INTERN-VALUE.
ENDIF.
ELSEIF LWA_INTERN-COL = 7.
record-VERAK = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 8.
LEN = STRLEN( LWA_INTERN-VALUE ).
IF LEN > 12.
MESSAGE I003(ZCO_LEN).
CLEAR GIT_record.
EXIT.
ELSE.
record-ABTEI = LWA_INTERN-VALUE.
ENDIF.
ELSEIF LWA_INTERN-COL = 9.
record-KOSAR = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 10.
record-KHINR = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 11.
record-PRCTR = LWA_INTERN-VALUE.
ENDIF.
AT END OF ROW.
L_ROW = L_ROW + 1.
APPEND record TO GIT_record.
CLEAR record.
ENDAT.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " SUB_UPLOAD_DATA
no standard page heading line-size 255.
include bdcrecx1.
TYPES: begin of T_IT_record,
* data element: KOKRS
KOKRS(004),
* data element: KOSTL
KOSTL(010),
* data element: DATAB
DATAB_ANFO(010),
* data element: DATBI
DATBI_ANFO(010),
* data element: KTEXT
KTEXT(020),
* data element: KLTXT
LTEXT(040),
* data element: VERAK
VERAK(020),
* data element: ABTEI
ABTEI(012),
* data element: KOSAR
KOSAR(001),
* data element: KHINR
KHINR(012),
* data element: PRCTR
PRCTR(010),
end of T_IT_record.
*&---------------------------------------------------------------------*
*& Internal Table
*&---------------------------------------------------------------------*
DATA: GIT_record TYPE STANDARD TABLE OF T_IT_record INITIAL SIZE 0.
*&---------------------------------------------------------------------*
*& Work Area
*&---------------------------------------------------------------------*
DATA: record TYPE T_IT_record.
*&---------------------------------------------------------------------*
*& Selection Criteria
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME .
PARAMETERS: P_FNAME TYPE LOCALFILE OBLIGATORY . " File Name
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN SKIP 1.
*----------------------------------------------------------------------*
* Variable
*----------------------------------------------------------------------*
DATA: V_FILENAME TYPE LOCALFILE. " File Name
*&---------------------------------------------------------------------*
*& At Selection Screen on value-request
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
*Get the browser to select the file
PERFORM SUB_GET_FILE.
start-of-selection.
* Move the value from selection to global variable
V_FILENAME = P_FNAME.
* Load the file into the Internal table
PERFORM SUB_UPLOAD_DATA.
perform open_group.
LOOP AT GIT_RECORD INTO RECORD.
perform bdc_dynpro using 'SAPLKMA1' '0200'.
perform bdc_field using 'BDC_CURSOR'
'CSKSZ-DATAB_ANFO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'CSKSZ-KOKRS'
record-KOKRS.
perform bdc_field using 'CSKSZ-KOSTL'
record-KOSTL.
perform bdc_field using 'CSKSZ-DATAB_ANFO'
record-DATAB_ANFO.
perform bdc_field using 'CSKSZ-DATBI_ANFO'
record-DATBI_ANFO.
perform bdc_dynpro using 'SAPLKMA1' '0299'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'CSKSZ-PRCTR'.
perform bdc_field using 'CSKSZ-KTEXT'
record-KTEXT.
perform bdc_field using 'CSKSZ-LTEXT'
record-LTEXT.
perform bdc_field using 'CSKSZ-VERAK'
record-VERAK.
perform bdc_field using 'CSKSZ-ABTEI'
record-ABTEI.
perform bdc_field using 'CSKSZ-KOSAR'
record-KOSAR.
perform bdc_field using 'CSKSZ-KHINR'
record-KHINR.
perform bdc_field using 'CSKSZ-PRCTR'
record-PRCTR.
perform bdc_transaction using 'KS01'.
ENDLOOP.
perform close_group.
*&---------------------------------------------------------------------*
*& Form SUB_GET_FILE
*----------------------------------------------------------------------*
FORM SUB_GET_FILE .
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FNAME.
ENDFORM. " SUB_GET_FILE
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA .
DATA: LWA_INTERN TYPE ALSMEX_TABLINE,
LIT_INTERN TYPE STANDARD TABLE OF ALSMEX_TABLINE INITIAL SIZE 0.
DATA LEN TYPE I.
DATA L_ROW TYPE KCD_EX_ROW_N. " Row
DATA int TYPE I. " Row
DATA CHECK.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = V_FILENAME
I_BEGIN_COL = 1 "P_FRMCOL
I_BEGIN_ROW = 5 "P_FRMLIN
I_END_COL = 11 "P_TOCOL
I_END_ROW = 65536 "P_TOLINE
TABLES
INTERN = LIT_INTERN
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0 .
MESSAGE TEXT-003 TYPE 'I'.
" Error in uploading the file from presentation server
LEAVE LIST-PROCESSING.
ELSE.
L_ROW = 1.
LOOP AT LIT_INTERN INTO LWA_INTERN.
IF L_ROW = LWA_INTERN-ROW.
IF LWA_INTERN-COL = 1.
record-KOKRS = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 2.
record-KOSTL = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 3.
record-DATAB_ANFO = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 4.
record-DATBI_ANFO = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 5.
LEN = STRLEN( LWA_INTERN-VALUE ).
IF LEN > 20.
MESSAGE I001(ZCO_LEN).
CLEAR GIT_record.
EXIT.
ELSE.
record-KTEXT = LWA_INTERN-VALUE.
ENDIF.
ELSEIF LWA_INTERN-COL = 6.
LEN = STRLEN( LWA_INTERN-VALUE ).
IF LEN > 40.
MESSAGE I002(ZCO_LEN).
CLEAR GIT_record.
EXIT.
ELSE.
record-LTEXT = LWA_INTERN-VALUE.
ENDIF.
ELSEIF LWA_INTERN-COL = 7.
record-VERAK = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 8.
LEN = STRLEN( LWA_INTERN-VALUE ).
IF LEN > 12.
MESSAGE I003(ZCO_LEN).
CLEAR GIT_record.
EXIT.
ELSE.
record-ABTEI = LWA_INTERN-VALUE.
ENDIF.
ELSEIF LWA_INTERN-COL = 9.
record-KOSAR = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 10.
record-KHINR = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 11.
record-PRCTR = LWA_INTERN-VALUE.
ENDIF.
AT END OF ROW.
L_ROW = L_ROW + 1.
APPEND record TO GIT_record.
CLEAR record.
ENDAT.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " SUB_UPLOAD_DATA
SAP ABAP - BDC for KA01
report ZCO_BDC_KA01
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
TYPES: begin of T_IT_record,
* data element: KOKRS
KOKRS(004),
* data element: KSTAR
KSTAR(010),
* data element: DATAB
DATAB_ANFO(010),
* data element: DATBI
DATBI_ANFO(010),
* data element: KATYP
KATYP(002),
end of T_IT_record.
*&---------------------------------------------------------------------*
*& Internal Table
*&---------------------------------------------------------------------*
DATA: GIT_record TYPE STANDARD TABLE OF T_IT_record INITIAL SIZE 0.
*&---------------------------------------------------------------------*
*& Work Area
*&---------------------------------------------------------------------*
DATA: record TYPE T_IT_record.
*&---------------------------------------------------------------------*
*& Selection Criteria
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME .
PARAMETERS: P_FNAME TYPE LOCALFILE OBLIGATORY . " File Name
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN SKIP 1.
*----------------------------------------------------------------------*
* Variable
*----------------------------------------------------------------------*
DATA: V_FILENAME TYPE LOCALFILE. " File Name
*&---------------------------------------------------------------------*
*& At Selection Screen on value-request
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
*Get the browser to select the file
PERFORM SUB_GET_FILE.
start-of-selection.
* Move the value from selection to global variable
V_FILENAME = P_FNAME.
* Load the file into the Internal table
PERFORM SUB_UPLOAD_DATA.
perform open_group.
LOOP AT GIT_RECORD INTO RECORD.
perform bdc_dynpro using 'SAPLKMA4' '0200'.
perform bdc_field using 'BDC_CURSOR'
'CSKBZ-KSTAR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'CSKBZ-KOKRS'
record-KOKRS.
perform bdc_field using 'CSKBZ-KSTAR'
record-KSTAR.
perform bdc_field using 'CSKBZ-DATAB_ANFO'
record-DATAB_ANFO.
perform bdc_field using 'CSKBZ-DATBI_ANFO'
record-DATBI_ANFO.
perform bdc_dynpro using 'SAPLKMA4' '0299'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'CSKBZ-KATYP'.
perform bdc_field using 'CSKBZ-KATYP'
record-KATYP.
perform bdc_transaction using 'KA01'.
ENDLOOP.
perform close_group.
*&---------------------------------------------------------------------*
*& Form SUB_GET_FILE
*----------------------------------------------------------------------*
FORM SUB_GET_FILE .
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FNAME.
ENDFORM. " SUB_GET_FILE
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA .
DATA: LWA_INTERN TYPE ALSMEX_TABLINE,
LIT_INTERN TYPE STANDARD TABLE OF ALSMEX_TABLINE INITIAL SIZE 0.
DATA LEN TYPE I.
DATA L_ROW TYPE KCD_EX_ROW_N. " Row
DATA int TYPE I. " Row
DATA CHECK.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = V_FILENAME
I_BEGIN_COL = 1 "P_FRMCOL
I_BEGIN_ROW = 5 "P_FRMLIN
I_END_COL = 11 "P_TOCOL
I_END_ROW = 65536 "P_TOLINE
TABLES
INTERN = LIT_INTERN
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0 .
MESSAGE TEXT-003 TYPE 'I'.
" Error in uploading the file from presentation server
LEAVE LIST-PROCESSING.
ELSE.
L_ROW = 1.
LOOP AT LIT_INTERN INTO LWA_INTERN.
IF L_ROW = LWA_INTERN-ROW.
IF LWA_INTERN-COL = 1.
record-KOKRS = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 2.
record-KSTAR = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 3.
record-DATAB_ANFO = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 4.
record-DATBI_ANFO = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 5.
record-KATYP = LWA_INTERN-VALUE.
ENDIF.
AT END OF ROW.
L_ROW = L_ROW + 1.
APPEND record TO GIT_record.
CLEAR record.
ENDAT.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " SUB_UPLOAD_DATA
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
TYPES: begin of T_IT_record,
* data element: KOKRS
KOKRS(004),
* data element: KSTAR
KSTAR(010),
* data element: DATAB
DATAB_ANFO(010),
* data element: DATBI
DATBI_ANFO(010),
* data element: KATYP
KATYP(002),
end of T_IT_record.
*&---------------------------------------------------------------------*
*& Internal Table
*&---------------------------------------------------------------------*
DATA: GIT_record TYPE STANDARD TABLE OF T_IT_record INITIAL SIZE 0.
*&---------------------------------------------------------------------*
*& Work Area
*&---------------------------------------------------------------------*
DATA: record TYPE T_IT_record.
*&---------------------------------------------------------------------*
*& Selection Criteria
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME .
PARAMETERS: P_FNAME TYPE LOCALFILE OBLIGATORY . " File Name
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN SKIP 1.
*----------------------------------------------------------------------*
* Variable
*----------------------------------------------------------------------*
DATA: V_FILENAME TYPE LOCALFILE. " File Name
*&---------------------------------------------------------------------*
*& At Selection Screen on value-request
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
*Get the browser to select the file
PERFORM SUB_GET_FILE.
start-of-selection.
* Move the value from selection to global variable
V_FILENAME = P_FNAME.
* Load the file into the Internal table
PERFORM SUB_UPLOAD_DATA.
perform open_group.
LOOP AT GIT_RECORD INTO RECORD.
perform bdc_dynpro using 'SAPLKMA4' '0200'.
perform bdc_field using 'BDC_CURSOR'
'CSKBZ-KSTAR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'CSKBZ-KOKRS'
record-KOKRS.
perform bdc_field using 'CSKBZ-KSTAR'
record-KSTAR.
perform bdc_field using 'CSKBZ-DATAB_ANFO'
record-DATAB_ANFO.
perform bdc_field using 'CSKBZ-DATBI_ANFO'
record-DATBI_ANFO.
perform bdc_dynpro using 'SAPLKMA4' '0299'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'CSKBZ-KATYP'.
perform bdc_field using 'CSKBZ-KATYP'
record-KATYP.
perform bdc_transaction using 'KA01'.
ENDLOOP.
perform close_group.
*&---------------------------------------------------------------------*
*& Form SUB_GET_FILE
*----------------------------------------------------------------------*
FORM SUB_GET_FILE .
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FNAME.
ENDFORM. " SUB_GET_FILE
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA .
DATA: LWA_INTERN TYPE ALSMEX_TABLINE,
LIT_INTERN TYPE STANDARD TABLE OF ALSMEX_TABLINE INITIAL SIZE 0.
DATA LEN TYPE I.
DATA L_ROW TYPE KCD_EX_ROW_N. " Row
DATA int TYPE I. " Row
DATA CHECK.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = V_FILENAME
I_BEGIN_COL = 1 "P_FRMCOL
I_BEGIN_ROW = 5 "P_FRMLIN
I_END_COL = 11 "P_TOCOL
I_END_ROW = 65536 "P_TOLINE
TABLES
INTERN = LIT_INTERN
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0 .
MESSAGE TEXT-003 TYPE 'I'.
" Error in uploading the file from presentation server
LEAVE LIST-PROCESSING.
ELSE.
L_ROW = 1.
LOOP AT LIT_INTERN INTO LWA_INTERN.
IF L_ROW = LWA_INTERN-ROW.
IF LWA_INTERN-COL = 1.
record-KOKRS = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 2.
record-KSTAR = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 3.
record-DATAB_ANFO = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 4.
record-DATBI_ANFO = LWA_INTERN-VALUE.
ELSEIF LWA_INTERN-COL = 5.
record-KATYP = LWA_INTERN-VALUE.
ENDIF.
AT END OF ROW.
L_ROW = L_ROW + 1.
APPEND record TO GIT_record.
CLEAR record.
ENDAT.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " SUB_UPLOAD_DATA
SAP ABAP - Used Transactions By User On Any Date.
REPORT zbasis_roles.
TABLES: usr01.
TYPES: BEGIN OF ty_usr01,
bname TYPE usr01-bname,
END OF ty_usr01.
TYPES: BEGIN OF ty_roles,
agr_name TYPE agr_users-agr_name,
uname TYPE agr_users-uname,
END OF ty_roles.
TYPES: BEGIN OF ty_tcodes,
agr_name TYPE agr_tcodes-agr_name,
tcode TYPE agr_tcodes-tcode,
END OF ty_tcodes.
DATA: v_count TYPE i.
DATA : it_tcodes TYPE TABLE OF ty_tcodes WITH HEADER LINE,
it_roles TYPE TABLE OF ty_roles WITH HEADER LINE,
it_usr01 TYPE TABLE OF ty_usr01 WITH HEADER LINE,
tasktype TYPE TABLE OF swncaggtasktype WITH HEADER LINE,
tasktimes TYPE TABLE OF swncaggtasktimes WITH HEADER LINE,
times TYPE TABLE OF swncaggtimes WITH HEADER LINE,
dbprocs TYPE TABLE OF swncaggdbprocs WITH HEADER LINE,
extsystem TYPE TABLE OF swncaggextsystem WITH HEADER LINE,
tcdet TYPE TABLE OF swncaggtcdet WITH HEADER LINE,
frontend TYPE TABLE OF swncaggfrontend WITH HEADER LINE,
memory TYPE TABLE OF swncaggmemory WITH HEADER LINE,
spoolact TYPE TABLE OF swncaggspoolact WITH HEADER LINE,
tablerec TYPE TABLE OF swncaggtablerec WITH HEADER LINE,
usertcode TYPE TABLE OF swncaggusertcode WITH HEADER LINE,
userworkload TYPE TABLE OF swncagguserworkload WITH HEADER LINE,
rfcclnt TYPE TABLE OF swncaggrfcclnt WITH HEADER LINE,
rfcclntdest TYPE TABLE OF swncaggrfcclntdest WITH HEADER LINE,
rfcsrvr TYPE TABLE OF swncaggrfcsrvr WITH HEADER LINE,
rfcsrvrdest TYPE TABLE OF swncaggrfcsrvrdest WITH HEADER LINE,
spool TYPE TABLE OF swncaggspool WITH HEADER LINE,
hitlist_database TYPE TABLE OF swnchitlist WITH HEADER LINE,
hitlist_resptime TYPE TABLE OF swnchitlist WITH HEADER LINE,
astat TYPE TABLE OF swncaggappstat WITH HEADER LINE,
ashitl_database TYPE TABLE OF swnchitlistappl WITH HEADER LINE,
ashitl_resptime TYPE TABLE OF swnchitlistappl WITH HEADER LINE,
comp_hierarchy TYPE TABLE OF swncaggcomphier WITH HEADER LINE,
org_units TYPE TABLE OF swncaggorgunit WITH HEADER LINE,
dbcon TYPE TABLE OF swncaggdbc WITH HEADER LINE,
vmc TYPE TABLE OF swncaggvmc WITH HEADER LINE,
websd TYPE TABLE OF swncaggwebdest WITH HEADER LINE,
webcd TYPE TABLE OF swncaggwebdest WITH HEADER LINE,
webs TYPE TABLE OF swncaggwebclnt WITH HEADER LINE,
webc TYPE TABLE OF swncaggwebclnt WITH HEADER LINE.
SELECT-OPTIONS: s_user FOR usr01-bname.
PARAMETERS: p_date TYPE swncdatum OBLIGATORY.
START-OF-SELECTION.
SELECT bname
FROM usr01
INTO TABLE it_usr01
WHERE bname IN s_user.
IF sy-subrc = 0.
SELECT agr_name
uname
FROM agr_users
INTO TABLE it_roles
FOR ALL ENTRIES IN it_usr01
WHERE uname = it_usr01-bname.
IF sy-subrc = 0.
SELECT agr_name
tcode
FROM agr_tcodes
INTO TABLE it_tcodes
FOR ALL ENTRIES IN it_roles
WHERE agr_name = it_roles-agr_name.
ENDIF.
ENDIF.
END-OF-SELECTION.
DATA: v_date TYPE swncdatum.
v_date+4(4) = p_date+0(4).
v_date+2(2) = p_date+4(2).
v_date+0(2) = p_date+6(2).
CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'
EXPORTING
component = 'hoerp02dev_NED_02'
* ASSIGNDSYS = SY-SYSID
periodtype = 'M'
periodstrt = p_date
* SUMMARY_ONLY = ' '
factor = 1000
TABLES
tasktype = tasktype
tasktimes = tasktimes
times = times
dbprocs = dbprocs
extsystem = extsystem
tcdet = tcdet
frontend = frontend
memory = memory
spoolact = spoolact
tablerec = tablerec
usertcode = usertcode
userworkload = userworkload
rfcclnt = rfcclnt
rfcclntdest = rfcclntdest
rfcsrvr = rfcsrvr
rfcsrvrdest = rfcsrvrdest
spool = spool
hitlist_database = hitlist_database
hitlist_resptime = hitlist_resptime
astat = astat
ashitl_database = ashitl_database
ashitl_resptime = ashitl_resptime
comp_hierarchy = comp_hierarchy
org_units = org_units
dbcon = dbcon
vmc = vmc
websd = websd
webcd = webcd
webs = webs
webc = webc
EXCEPTIONS
no_data_found = 1
OTHERS = 2.
DELETE usertcode[] WHERE entry_id = 'Logoff'.
DELETE usertcode[] WHERE entry_id = 'MainMenu'.
LOOP AT it_usr01.
WRITE:/ 'User Name: ', it_usr01-bname.
WRITE:/ 'Role Name:' .
LOOP AT it_roles WHERE uname = it_usr01-bname
AND agr_name+(1) = 'Z'.
WRITE:/ it_roles-agr_name.
ENDLOOP .
WRITE:/ 'Used Transactions for the entered date' , p_date ,'is:'.
LOOP AT usertcode WHERE account = it_usr01-bname.
v_count = v_count + 1.
WRITE:/ v_count,
usertcode-entry_id.
ENDLOOP.
CLEAR : v_count.
ENDLOOP.
TABLES: usr01.
TYPES: BEGIN OF ty_usr01,
bname TYPE usr01-bname,
END OF ty_usr01.
TYPES: BEGIN OF ty_roles,
agr_name TYPE agr_users-agr_name,
uname TYPE agr_users-uname,
END OF ty_roles.
TYPES: BEGIN OF ty_tcodes,
agr_name TYPE agr_tcodes-agr_name,
tcode TYPE agr_tcodes-tcode,
END OF ty_tcodes.
DATA: v_count TYPE i.
DATA : it_tcodes TYPE TABLE OF ty_tcodes WITH HEADER LINE,
it_roles TYPE TABLE OF ty_roles WITH HEADER LINE,
it_usr01 TYPE TABLE OF ty_usr01 WITH HEADER LINE,
tasktype TYPE TABLE OF swncaggtasktype WITH HEADER LINE,
tasktimes TYPE TABLE OF swncaggtasktimes WITH HEADER LINE,
times TYPE TABLE OF swncaggtimes WITH HEADER LINE,
dbprocs TYPE TABLE OF swncaggdbprocs WITH HEADER LINE,
extsystem TYPE TABLE OF swncaggextsystem WITH HEADER LINE,
tcdet TYPE TABLE OF swncaggtcdet WITH HEADER LINE,
frontend TYPE TABLE OF swncaggfrontend WITH HEADER LINE,
memory TYPE TABLE OF swncaggmemory WITH HEADER LINE,
spoolact TYPE TABLE OF swncaggspoolact WITH HEADER LINE,
tablerec TYPE TABLE OF swncaggtablerec WITH HEADER LINE,
usertcode TYPE TABLE OF swncaggusertcode WITH HEADER LINE,
userworkload TYPE TABLE OF swncagguserworkload WITH HEADER LINE,
rfcclnt TYPE TABLE OF swncaggrfcclnt WITH HEADER LINE,
rfcclntdest TYPE TABLE OF swncaggrfcclntdest WITH HEADER LINE,
rfcsrvr TYPE TABLE OF swncaggrfcsrvr WITH HEADER LINE,
rfcsrvrdest TYPE TABLE OF swncaggrfcsrvrdest WITH HEADER LINE,
spool TYPE TABLE OF swncaggspool WITH HEADER LINE,
hitlist_database TYPE TABLE OF swnchitlist WITH HEADER LINE,
hitlist_resptime TYPE TABLE OF swnchitlist WITH HEADER LINE,
astat TYPE TABLE OF swncaggappstat WITH HEADER LINE,
ashitl_database TYPE TABLE OF swnchitlistappl WITH HEADER LINE,
ashitl_resptime TYPE TABLE OF swnchitlistappl WITH HEADER LINE,
comp_hierarchy TYPE TABLE OF swncaggcomphier WITH HEADER LINE,
org_units TYPE TABLE OF swncaggorgunit WITH HEADER LINE,
dbcon TYPE TABLE OF swncaggdbc WITH HEADER LINE,
vmc TYPE TABLE OF swncaggvmc WITH HEADER LINE,
websd TYPE TABLE OF swncaggwebdest WITH HEADER LINE,
webcd TYPE TABLE OF swncaggwebdest WITH HEADER LINE,
webs TYPE TABLE OF swncaggwebclnt WITH HEADER LINE,
webc TYPE TABLE OF swncaggwebclnt WITH HEADER LINE.
SELECT-OPTIONS: s_user FOR usr01-bname.
PARAMETERS: p_date TYPE swncdatum OBLIGATORY.
START-OF-SELECTION.
SELECT bname
FROM usr01
INTO TABLE it_usr01
WHERE bname IN s_user.
IF sy-subrc = 0.
SELECT agr_name
uname
FROM agr_users
INTO TABLE it_roles
FOR ALL ENTRIES IN it_usr01
WHERE uname = it_usr01-bname.
IF sy-subrc = 0.
SELECT agr_name
tcode
FROM agr_tcodes
INTO TABLE it_tcodes
FOR ALL ENTRIES IN it_roles
WHERE agr_name = it_roles-agr_name.
ENDIF.
ENDIF.
END-OF-SELECTION.
DATA: v_date TYPE swncdatum.
v_date+4(4) = p_date+0(4).
v_date+2(2) = p_date+4(2).
v_date+0(2) = p_date+6(2).
CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'
EXPORTING
component = 'hoerp02dev_NED_02'
* ASSIGNDSYS = SY-SYSID
periodtype = 'M'
periodstrt = p_date
* SUMMARY_ONLY = ' '
factor = 1000
TABLES
tasktype = tasktype
tasktimes = tasktimes
times = times
dbprocs = dbprocs
extsystem = extsystem
tcdet = tcdet
frontend = frontend
memory = memory
spoolact = spoolact
tablerec = tablerec
usertcode = usertcode
userworkload = userworkload
rfcclnt = rfcclnt
rfcclntdest = rfcclntdest
rfcsrvr = rfcsrvr
rfcsrvrdest = rfcsrvrdest
spool = spool
hitlist_database = hitlist_database
hitlist_resptime = hitlist_resptime
astat = astat
ashitl_database = ashitl_database
ashitl_resptime = ashitl_resptime
comp_hierarchy = comp_hierarchy
org_units = org_units
dbcon = dbcon
vmc = vmc
websd = websd
webcd = webcd
webs = webs
webc = webc
EXCEPTIONS
no_data_found = 1
OTHERS = 2.
DELETE usertcode[] WHERE entry_id = 'Logoff'.
DELETE usertcode[] WHERE entry_id = 'MainMenu'.
LOOP AT it_usr01.
WRITE:/ 'User Name: ', it_usr01-bname.
WRITE:/ 'Role Name:' .
LOOP AT it_roles WHERE uname = it_usr01-bname
AND agr_name+(1) = 'Z'.
WRITE:/ it_roles-agr_name.
ENDLOOP .
WRITE:/ 'Used Transactions for the entered date' , p_date ,'is:'.
LOOP AT usertcode WHERE account = it_usr01-bname.
v_count = v_count + 1.
WRITE:/ v_count,
usertcode-entry_id.
ENDLOOP.
CLEAR : v_count.
ENDLOOP.
Subscribe to:
Posts (Atom)