Submit program in SAP ABAP programming language
TYPES : BEGIN OF ty_final,
*-------Header
order_no TYPE afko-aufnr, "Order No
order_date TYPE afko-gstrp, "aufk-erdat, "Order Date" afko-gstrp
* gstrp TYPE afko-gstrp, "Order Date
sku_no TYPE afko-plnbez, "SKU No
sku_des TYPE makt-maktx, "SKU Desc
worcenter_des TYPE crtx-ktext, "worcenter des
plant TYPE mseg-werks, "Plant
order_qty TYPE afko-gamng, "Order Qty
uom TYPE afko-gmein, "UOM
base_qty TYPE afko-gamng, "Base Qty
*-------Line Item
per_hour_standard_quantity TYPE afko-gamng, "Per Hour Standard Quantity
gamng_r TYPE afko-gamng, "Per Hour Standard Quantity
uom_2 TYPE afko-gmein, "UOM
confirmation_date TYPE afru-iedd, "Confirmation Date
confirmation_time TYPE afru-iedz, "Confirmation Time
confirmed_quantity TYPE afru-gmnga, "Confirmed Quantity
uom_3 TYPE afru-meinh, "UOM
standard_setup_time TYPE afru-ism02, "Standard Setup Time
setup_time TYPE afru-ism01, "Setup Time
"Standard Regular Labor
machine_time TYPE afru-ism02, "Machine Time
machine_time1 TYPE afru-ism02, "Machine Time
regular_labour TYPE afru-ism03, "Regular Labour
regular_labour1 TYPE afru-ism03, "Regular Labour
total_labor TYPE afru-ism03, "total Labor
calculated_labour TYPE afru-ism03, "Calculated Labour
"Standard Overtime Labor
overtime_labour TYPE afru-ism04, "Overtime Labour
overtime_labour1 TYPE afru-ism04, "Overtime Labour
break_time TYPE afru-zzism07, "Break Time
machine_eff TYPE p LENGTH 9 DECIMALS 2, "Machine EFF
gmnga_leff TYPE p LENGTH 9 DECIMALS 2, "Labour EFF
downtime TYPE afru-zzism07, "Downtime
down_time_reason TYPE afru-grund, "Down Time Reason
down_time_reason_desc TYPE char50, "Down Time Reason Desc
ism05_s TYPE afru-ism05,
standard_mhe TYPE afru-ism05, "Standard MHE
"Recovery Efficiency
matnr1 TYPE matnr,
maktx1 TYPE maktx,
reqqty(16) TYPE p DECIMALS 3,
conqty(16) TYPE p DECIMALS 3,
scrp_qty(16) TYPE p DECIMALS 3,
actual_qty(16) TYPE p DECIMALS 3,
uom1 TYPE meins,
reqfig TYPE dmbtr,
reqqtyt TYPE char20,
line_color(4) TYPE c, "Used to store row color attributes
END OF ty_final,
BEGIN OF ty_final2,
order_no TYPE aufnr,
order_date TYPE pm_ordgstrp,
sku_no TYPE matnr,
sku_des TYPE maktx,
worcenter_des TYPE cr_ktext,
plant TYPE werks_d,
order_qty TYPE gamng,
uom TYPE meins,
confirmation_date TYPE ru_iedd,
confirmation_time TYPE ru_iedz,
confirmed_quantity TYPE ru_gmnga,
uom_2 TYPE ru_vorme,
matnr1 TYPE matnr,
maktx1 TYPE maktx,
reqqty(16) TYPE p DECIMALS 3,
conqty(16) TYPE p DECIMALS 3,
scrp_qty(16) TYPE p DECIMALS 3,
actual_qty(16) TYPE p DECIMALS 3,
uom1 TYPE meins,
reqfig TYPE dmbtr,
* reqqtyt TYPE char20,
* line_color(4) TYPE c,
* component TYPE matnr,
* com_des TYPE maktx,
* reqqty TYPE D,
* conqty TYPE d,
* SCRP_QTY Type d,
* ACTUAL_QTY Type d,
* UOM1 Type MEINS,
* REQUIRED_YIELD Type DMBTR,
END OF ty_final2.
DATA : ex_prod_effi_vari LIKE zzprod_effi_vari.
DATA : lv_date_from TYPE pm_ordgstrp.
DATA : lv_date_to TYPE pm_ordgstrp,
gt_ex_prod_effi_vari TYPE TABLE OF zzprod_effi_vari,
gt_exp_pro_effi_vari2 TYPE TABLE OF zzprod_effi_vari,
gt_exp_pro_effi_vari3 TYPE TABLE OF zzprod_effi_vari_d1,
gs_exp_pro_effi_vari3 TYPE zzprod_effi_vari_d1.
DATA : lv_day TYPE dtresr-weekday.
* REFRESH git_final.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
date = im_date
IMPORTING
weekday = lv_day.
IF lv_day = 'Monday'.
lv_date = im_date - 3.
ELSE.
lv_date = im_date - 1.
ENDIF.
* CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
* EXPORTING
* iv_date = im_date
* IMPORTING
* ev_month_begin_date = lv_date_from
* ev_month_end_date = lv_date_to.
* **************************************************************************************************************
* **************************************************************************************************************
DATA : git_final TYPE STANDARD TABLE OF ty_final,
gs_final TYPE ty_final,
git_final1 TYPE STANDARD TABLE OF ty_final,
gs_final1 TYPE ty_final,
git_final2 TYPE STANDARD TABLE OF ty_final,
gs_final2 TYPE ty_final.
RANGES : r_werks FOR marc-werks,
r_dauat FOR afpo-dauat,
r_date FOR afko-gstrp,
r_aufnr FOR afru-aufnr.
***************************************
DATA: lr_prd TYPE REF TO data.
* DATA: lr_prs TYPE REF TO data.
DATA: lr_query TYPE REF TO data.
FIELD-SYMBOLS:
<lt_prd> TYPE STANDARD TABLE,
<ls_prd> TYPE any,
* <lt_prs> TYPE STANDARD TABLE,
* <ls_prs> TYPE any,
<lv_field> TYPE any.
FIELD-SYMBOLS:
<lt_query> TYPE STANDARD TABLE,
<ls_query> TYPE any,
<lv_field1> TYPE any.
DATA: text TYPE c LENGTH 10,
rspar_tab TYPE TABLE OF rsparams,
rspar_line LIKE LINE OF rspar_tab,
range_tab LIKE RANGE OF text,
range_line LIKE LINE OF range_tab.
***************************************
REFRESH : r_werks,r_dauat,r_date,r_aufnr.
****For Prod. Order
* r_aufnr-sign = 'I'.
* r_aufnr-option = 'EQ'.
* r_aufnr-low = '000001000413'.
* APPEND r_aufnr.
****For Plant
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = '2101'.
APPEND r_werks.
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = '2102'.
APPEND r_werks.
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = '2105'.
APPEND r_werks.
****For Order Type
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LA01'.
APPEND r_dauat.
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LA07'.
APPEND r_dauat.
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LA04'.
APPEND r_dauat.
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LAJ1'.
APPEND r_dauat.
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LATR'.
APPEND r_dauat.
****For Date
r_date-sign = 'I'.
r_date-option = 'EQ'.
r_date-low = lv_date.
r_date-high = im_date.
APPEND r_date.
*********************************************
****Data Fatch form Prod Eff. n Vari. Report
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).
SUBMIT zf2prus062_prd_eff_v1 WITH s_dauat IN r_dauat "s_aufnr in r_aufnr
WITH s_werks IN r_werks
WITH s_date IN r_date
WITH r_detail = 'X'
WITH r_sum = ' '
WITH r_eff = ' '
AND RETURN.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lr_prd ).
IF lr_prd IS NOT INITIAL.
ASSIGN lr_prd->* TO <lt_prd>.
IF <lt_prd> IS NOT INITIAL.
LOOP AT <lt_prd> ASSIGNING <ls_prd>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE
<ls_prd> TO <lv_field>.
IF sy-subrc <> 0.
EXIT.
ELSE.
" do your data validation here...
ENDIF.
ENDDO.
ENDLOOP.
APPEND LINES OF <lt_prd> TO git_final.
ENDIF.
cl_salv_bs_runtime_info=>clear_all( ).
ELSE.
* message 'No Data Found' type 'I'.
ENDIF.
IF git_final[] IS NOT INITIAL.
LOOP AT git_final INTO gs_final.
MOVE-CORRESPONDING gs_final TO ex_prod_effi_vari.
APPEND ex_prod_effi_vari TO gt_ex_prod_effi_vari.
CLEAR ex_prod_effi_vari.
ENDLOOP.
MOVE gt_ex_prod_effi_vari TO zsd_deep-zsd_deep.
ENDIF.
*-------Header
order_no TYPE afko-aufnr, "Order No
order_date TYPE afko-gstrp, "aufk-erdat, "Order Date" afko-gstrp
* gstrp TYPE afko-gstrp, "Order Date
sku_no TYPE afko-plnbez, "SKU No
sku_des TYPE makt-maktx, "SKU Desc
worcenter_des TYPE crtx-ktext, "worcenter des
plant TYPE mseg-werks, "Plant
order_qty TYPE afko-gamng, "Order Qty
uom TYPE afko-gmein, "UOM
base_qty TYPE afko-gamng, "Base Qty
*-------Line Item
per_hour_standard_quantity TYPE afko-gamng, "Per Hour Standard Quantity
gamng_r TYPE afko-gamng, "Per Hour Standard Quantity
uom_2 TYPE afko-gmein, "UOM
confirmation_date TYPE afru-iedd, "Confirmation Date
confirmation_time TYPE afru-iedz, "Confirmation Time
confirmed_quantity TYPE afru-gmnga, "Confirmed Quantity
uom_3 TYPE afru-meinh, "UOM
standard_setup_time TYPE afru-ism02, "Standard Setup Time
setup_time TYPE afru-ism01, "Setup Time
"Standard Regular Labor
machine_time TYPE afru-ism02, "Machine Time
machine_time1 TYPE afru-ism02, "Machine Time
regular_labour TYPE afru-ism03, "Regular Labour
regular_labour1 TYPE afru-ism03, "Regular Labour
total_labor TYPE afru-ism03, "total Labor
calculated_labour TYPE afru-ism03, "Calculated Labour
"Standard Overtime Labor
overtime_labour TYPE afru-ism04, "Overtime Labour
overtime_labour1 TYPE afru-ism04, "Overtime Labour
break_time TYPE afru-zzism07, "Break Time
machine_eff TYPE p LENGTH 9 DECIMALS 2, "Machine EFF
gmnga_leff TYPE p LENGTH 9 DECIMALS 2, "Labour EFF
downtime TYPE afru-zzism07, "Downtime
down_time_reason TYPE afru-grund, "Down Time Reason
down_time_reason_desc TYPE char50, "Down Time Reason Desc
ism05_s TYPE afru-ism05,
standard_mhe TYPE afru-ism05, "Standard MHE
"Recovery Efficiency
matnr1 TYPE matnr,
maktx1 TYPE maktx,
reqqty(16) TYPE p DECIMALS 3,
conqty(16) TYPE p DECIMALS 3,
scrp_qty(16) TYPE p DECIMALS 3,
actual_qty(16) TYPE p DECIMALS 3,
uom1 TYPE meins,
reqfig TYPE dmbtr,
reqqtyt TYPE char20,
line_color(4) TYPE c, "Used to store row color attributes
END OF ty_final,
BEGIN OF ty_final2,
order_no TYPE aufnr,
order_date TYPE pm_ordgstrp,
sku_no TYPE matnr,
sku_des TYPE maktx,
worcenter_des TYPE cr_ktext,
plant TYPE werks_d,
order_qty TYPE gamng,
uom TYPE meins,
confirmation_date TYPE ru_iedd,
confirmation_time TYPE ru_iedz,
confirmed_quantity TYPE ru_gmnga,
uom_2 TYPE ru_vorme,
matnr1 TYPE matnr,
maktx1 TYPE maktx,
reqqty(16) TYPE p DECIMALS 3,
conqty(16) TYPE p DECIMALS 3,
scrp_qty(16) TYPE p DECIMALS 3,
actual_qty(16) TYPE p DECIMALS 3,
uom1 TYPE meins,
reqfig TYPE dmbtr,
* reqqtyt TYPE char20,
* line_color(4) TYPE c,
* component TYPE matnr,
* com_des TYPE maktx,
* reqqty TYPE D,
* conqty TYPE d,
* SCRP_QTY Type d,
* ACTUAL_QTY Type d,
* UOM1 Type MEINS,
* REQUIRED_YIELD Type DMBTR,
END OF ty_final2.
DATA : ex_prod_effi_vari LIKE zzprod_effi_vari.
DATA : lv_date_from TYPE pm_ordgstrp.
DATA : lv_date_to TYPE pm_ordgstrp,
gt_ex_prod_effi_vari TYPE TABLE OF zzprod_effi_vari,
gt_exp_pro_effi_vari2 TYPE TABLE OF zzprod_effi_vari,
gt_exp_pro_effi_vari3 TYPE TABLE OF zzprod_effi_vari_d1,
gs_exp_pro_effi_vari3 TYPE zzprod_effi_vari_d1.
DATA : lv_day TYPE dtresr-weekday.
* REFRESH git_final.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
date = im_date
IMPORTING
weekday = lv_day.
IF lv_day = 'Monday'.
lv_date = im_date - 3.
ELSE.
lv_date = im_date - 1.
ENDIF.
* CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
* EXPORTING
* iv_date = im_date
* IMPORTING
* ev_month_begin_date = lv_date_from
* ev_month_end_date = lv_date_to.
* **************************************************************************************************************
* **************************************************************************************************************
DATA : git_final TYPE STANDARD TABLE OF ty_final,
gs_final TYPE ty_final,
git_final1 TYPE STANDARD TABLE OF ty_final,
gs_final1 TYPE ty_final,
git_final2 TYPE STANDARD TABLE OF ty_final,
gs_final2 TYPE ty_final.
RANGES : r_werks FOR marc-werks,
r_dauat FOR afpo-dauat,
r_date FOR afko-gstrp,
r_aufnr FOR afru-aufnr.
***************************************
DATA: lr_prd TYPE REF TO data.
* DATA: lr_prs TYPE REF TO data.
DATA: lr_query TYPE REF TO data.
FIELD-SYMBOLS:
<lt_prd> TYPE STANDARD TABLE,
<ls_prd> TYPE any,
* <lt_prs> TYPE STANDARD TABLE,
* <ls_prs> TYPE any,
<lv_field> TYPE any.
FIELD-SYMBOLS:
<lt_query> TYPE STANDARD TABLE,
<ls_query> TYPE any,
<lv_field1> TYPE any.
DATA: text TYPE c LENGTH 10,
rspar_tab TYPE TABLE OF rsparams,
rspar_line LIKE LINE OF rspar_tab,
range_tab LIKE RANGE OF text,
range_line LIKE LINE OF range_tab.
***************************************
REFRESH : r_werks,r_dauat,r_date,r_aufnr.
****For Prod. Order
* r_aufnr-sign = 'I'.
* r_aufnr-option = 'EQ'.
* r_aufnr-low = '000001000413'.
* APPEND r_aufnr.
****For Plant
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = '2101'.
APPEND r_werks.
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = '2102'.
APPEND r_werks.
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = '2105'.
APPEND r_werks.
****For Order Type
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LA01'.
APPEND r_dauat.
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LA07'.
APPEND r_dauat.
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LA04'.
APPEND r_dauat.
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LAJ1'.
APPEND r_dauat.
r_dauat-sign = 'I'.
r_dauat-option = 'EQ'.
r_dauat-low = 'LATR'.
APPEND r_dauat.
****For Date
r_date-sign = 'I'.
r_date-option = 'EQ'.
r_date-low = lv_date.
r_date-high = im_date.
APPEND r_date.
*********************************************
****Data Fatch form Prod Eff. n Vari. Report
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).
SUBMIT zf2prus062_prd_eff_v1 WITH s_dauat IN r_dauat "s_aufnr in r_aufnr
WITH s_werks IN r_werks
WITH s_date IN r_date
WITH r_detail = 'X'
WITH r_sum = ' '
WITH r_eff = ' '
AND RETURN.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lr_prd ).
IF lr_prd IS NOT INITIAL.
ASSIGN lr_prd->* TO <lt_prd>.
IF <lt_prd> IS NOT INITIAL.
LOOP AT <lt_prd> ASSIGNING <ls_prd>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE
<ls_prd> TO <lv_field>.
IF sy-subrc <> 0.
EXIT.
ELSE.
" do your data validation here...
ENDIF.
ENDDO.
ENDLOOP.
APPEND LINES OF <lt_prd> TO git_final.
ENDIF.
cl_salv_bs_runtime_info=>clear_all( ).
ELSE.
* message 'No Data Found' type 'I'.
ENDIF.
IF git_final[] IS NOT INITIAL.
LOOP AT git_final INTO gs_final.
MOVE-CORRESPONDING gs_final TO ex_prod_effi_vari.
APPEND ex_prod_effi_vari TO gt_ex_prod_effi_vari.
CLEAR ex_prod_effi_vari.
ENDLOOP.
MOVE gt_ex_prod_effi_vari TO zsd_deep-zsd_deep.
ENDIF.
Comments
Post a Comment