Method: z100217 - Inboundii - Si - Ia - Work - I Notify
Method: z100217 - Inboundii - Si - Ia - Work - I Notify
Method: z100217 - Inboundii - Si - Ia - Work - I Notify
*----------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : {Delete Table entries when workinstruction is *
* Deleted } *
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 04-03-2016
* Reason : NA
* Searchkey :
* Transportnumber : DV9K901707
*---------------------------------------------------------------------*
* Modification : Status Profile of production order was wrongly assigned
* Changes made to change profile from ZPP00001 to ZPP00002
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy):
* Reason : NA
* Searchkey : DV9K901978
* Transportnumber : DV9K901978
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Code changes done to insert Scrap component into workins
truction
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 02/04/2016
* Reason : NA
* Searchkey : DV9K902507
* Transportnumber : DV9K902507
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Changes made to fix the problem of Scrap Qty
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 13/04/2016
* Reason : Incident 591243
* Searchkey : DV9K902740
* Transportnumber : DV9K902740
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Operation Number logic changed
* Modified by : Bhaskar
* Date (dd-mm-yyyy): 14-04-2016
* Reason : incident 591243
* Searchkey : DV9K902864
* Transportnumber : DV9K902864
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Unit of Conversion changes
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 15/04/2016
* Reason : incident 591243
* Searchkey : DV9K902874
* Transportnumber : DV9K902874
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Handled Negative scrap QTy
* Modified by : Bhaskar
* Date (dd-mm-yyyy): 15/04-2016
* Reason : incident 591243
* Searchkey : DV9K902913
* Transportnumber : DV9K902913
*---------------------------------------------------------------------*
*-----------L O C A L T Y P E S D E C L A R A T I O N------------------
*
TYPES : BEGIN OF lty_zpp_wi_component,
bwart TYPE bwart, "Movement type
family TYPE zfamily, "Family
type TYPE ztype, "Type
width TYPE zwidth, "Width
length TYPE zlength, "Length
matnr TYPE matnr, "Material Number
END OF lty_zpp_wi_component.
*----------------------------------------------------------------------------
----*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------------
----*
DATA : ls_orderdata TYPE bapi_pp_order_create, "Orderdata
lt_hdr_user_status TYPE cose_t_hdr_user_stat, "Header User Stat
us
lt_sequence TYPE cose_t_sequence, "Sequence
lt_opr_user_status TYPE cose_t_opr_user_stat, "Operation user s
tatus
lt_component TYPE zpp_t_component, "Component
ls_component TYPE zpp_s_component, "Component struct
ure
lt_operation TYPE zpp_t_operation, "Operation table
ls_operation TYPE zpp_s_operation, "Operation struct
ure
ls_return TYPE bapiret2, "Bapi Return
ls_header TYPE z100217_inboundsi_ia_work_inst, "Proxy H
eader structure
lt_material TYPE z100217_inboundmaterial_tab, "Proxy M
aterial table
ls_material TYPE z100217_inboundmaterial, "Proxy M
aterial Structure
lt_order TYPE z100217_inboundsi_ia_work__tab, "Proxy O
rder table
ls_order TYPE z100217_inboundsi_ia_work_ins2, "Proxy O
rder structure
lt_char TYPE z100217_inboundsi_ia_work_tab1, "Proxy C
haracteristic
ls_char TYPE z100217_inboundsi_ia_work_ins5, "Proxy C
haracteristic structure
lt_zpp_wi_component TYPE STANDARD TABLE OF lty_zpp_wi_component IN
ITIAL SIZE 0, "Component table
ls_zpp_wi_component TYPE lty_zpp_wi_component, "Compone
nt structure
lv_family TYPE atnam, "Family
lv_type TYPE atnam, "Type
lv_width(16) TYPE p DECIMALS 5, "
Width
lv_length(16) TYPE p DECIMALS 5, "
Length
lv_objid(10) TYPE c, "Object
ID
lv_arbpl TYPE arbpl, "Workcen
ter
lv_steus TYPE steus, "Control
Key
lv_vornr TYPE vornr, "Operati
on number
lv_sequence TYPE plnfolge, "Sequenc
e
lt_usr_stat TYPE cose_t_hdr_user_stat, "User st
atus
ls_usr_stat TYPE cose_s_hdr_user_stat, "User st
atus structure
lt_log TYPE zca_t_error_log_struc, "Log tab
le
ls_log TYPE bca_str_rel_message, "Log Str
ucture
lt_return TYPE STANDARD TABLE OF bapiret2 INITIAL SIZE
0, "BAPI Return table
lv_matnr TYPE matnr, "Heade
r Material
lt_del_prod_ord TYPE STANDARD TABLE OF bapi_order_key INITIAL
SIZE 0, "Delete work Instruction
lt_bapi_order_return TYPE STANDARD TABLE OF bapi_order_return INITI
AL SIZE 0, "BAPI Return
ls_del_prod_ord TYPE bapi_order_key,
"Delete work Instruction
ls_bapi_order_return TYPE bapi_order_return,
"BAPI Return
lv_index TYPE sy-tabix,
"Tab Index
lv_order_qty_sc TYPE gamng,
"Total order quantity Sc
lv_order_qty_tot_sc TYPE gamng,
" Total ordr Qty
lv_order_qty_finl_sc TYPE gamng,
" Total ordr Qty
lv_matnr_sc TYPE matnr,
"Scrap Material
lv_aposn_sc TYPE aposn,
"BOM item number
lv_werks_sc TYPE werks_d,
"Plant
lv_operation_sc TYPE vornr,
"Operation
lv_sequence_sc TYPE plnfolge,
"Sequence
lv_family_sc TYPE atwrt,
"Family for SC
lv_base_unit TYPE meins,
"Base Unit of Measure
* Begin of A236938 DV9K902740
lv_meins TYPE meins,
"Base UOM
lv_thickness TYPE p DECIMALS 5,
"Thickness
lv_coil_density TYPE p DECIMALS 5,
"Density
lv_coil_thickness TYPE p DECIMALS 5,
"Thickness
lv_density TYPE p DECIMALS 5,
"Density
* Begin of A236938 DV9K902874
lv_coil_family TYPE atnam,
"Family
lv_width_uom TYPE atwrt,
"Width
lv_length_uom TYPE atwrt,
"Length
lv_density_uom TYPE atwrt,
"Density
lv_thickness_uom TYPE atwrt.
"Thickness
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------------
---*
CONSTANTS : lc_ord_type TYPE auart VALUE 'ZPC1',
"Order Type
lc_family TYPE atnam VALUE 'Z_FAMILY',
"Family
lc_type TYPE atnam VALUE 'Z_TYPE',
"Type
lc_width TYPE atnam VALUE 'Z_WIDTH',
"Width
lc_length TYPE atnam VALUE 'Z_LENGTH',
"Length
lc_co(2) TYPE c VALUE 'CO',
"Coil
lc_rm(2) TYPE c VALUE 'RM',
"Reminant
lc_sc(2) TYPE c VALUE 'SC',
"Scrap
lc_in(2) TYPE c VALUE 'IN',
"Intermediate
lc_fp(2) TYPE c VALUE 'FP',
"Finish Product
lc_success(1) TYPE c VALUE 'S',
"Success
lc_warn(1) TYPE c VALUE 'W',
"Warning
lc_info(1) TYPE c VALUE 'I',
"Information
lc_extnumber(9) TYPE c VALUE 'I_PP_002',
"Ricef Object ID
lc_length_val(5) TYPE p VALUE '15000',
"Length Value
lc_width_val(3) TYPE p VALUE '600',
"Width Value
lc_sheet(2) TYPE c VALUE 'SH',
"Sheet
lc_coil(2) TYPE c VALUE 'CO',
"Coil
lc_strip(2) TYPE c VALUE 'ST',
"Strips
lc_del(3) TYPE c VALUE 'DEL',
"Delete Status
* Begin of A236938 DV9K902740
lc_thickness TYPE atnam VALUE 'Z_THICKNESS',
"Density
lc_density TYPE atnam VALUE 'Z_DENSITY',
"Thickness
lc_kg TYPE meins VALUE 'KG',
"KG
lc_mtk TYPE meins VALUE 'M2',
"Metere Square
* Begin of A236938 DV9K902864
lc_vornr TYPE vornr VALUE '0010',
lc_alum_denisty TYPE i VALUE '2700',
"AlUM Density
lc_denisty TYPE i VALUE '8000',
"Value of Density
lc_alum(4) TYPE c VALUE 'ALUM'.
"ALUM
* End of A236938 DV9K902864
* End of A236938 DV9K902740
*----------------------------------------------------------------------------
----*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lt_hdr_user_status,
lt_sequence,
lt_opr_user_status,
lt_component,
lt_operation,
lt_material,
lt_order,
lt_char,
lt_zpp_wi_component,
lt_usr_stat,
lt_log,
lt_return,
lt_del_prod_ord,
lt_bapi_order_return.
CLEAR : ls_orderdata,
ls_component,
ls_operation,
ls_return,
ls_header,
ls_material,
ls_order,
ls_char,
ls_zpp_wi_component,
lv_family,
lv_type,
lv_width,
lv_objid ,
lv_arbpl,
lv_vornr,
lv_sequence,
ls_usr_stat,
ls_log,
lv_matnr,
ls_order,
ls_del_prod_ord,
ls_bapi_order_return,
lv_index,
lv_steus,
lv_order_qty_sc ,
lv_order_qty_tot_sc,
lv_matnr_sc ,
lv_aposn_sc,
lv_werks_sc ,
lv_operation_sc ,
lv_sequence_sc,
lv_order_qty_finl_sc,
lv_base_unit,
* Begin of A236938 DV9K902740
lv_meins,
lv_thickness,
lv_coil_density,
lv_coil_thickness,
lv_density,
* Begin of A236938 DV9K902874
lv_coil_family,
lv_width_uom,
lv_length_uom,
lv_density_uom,
lv_thickness_uom.
* End of A236938 DV9K902874
* End of A236938 DV9K902740
*----------------------------------------------------------------------*
* Assign Header Data
ls_header = input-work_instruction_header.
* Assign Material Data
lt_material[] = input-materials-sequence-material[].
* Assign Order Data
lt_order[] = input-orders-sequence-order[].
IF ls_header-object_status EQ lc_del.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_header-work_instruction_number
IMPORTING
output = ls_header-work_instruction_number.
ls_del_prod_ord-order_number = ls_header-work_instruction_number.
APPEND ls_del_prod_ord TO lt_del_prod_ord.
CLEAR : ls_del_prod_ord.
* Begin of A236938 DV9K901707
CALL FUNCTION 'BAPI_PRODORD_COMPLETE_TECH'
IMPORTING
return = ls_return
TABLES
orders = lt_del_prod_ord
detail_return = lt_bapi_order_return.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ELSE.
ENDIF.
ls_operation-work_center = lv_arbpl.
ls_operation-control_key = lv_steus.
ENDIF.
ENDIF.
* Assign operation
ls_operation-setup_time = ls_header-setup_time.
ls_operation-proc_time = ls_header-proc_time.
* Assign Component
LOOP AT lt_material INTO ls_material.
lv_index = sy-tabix.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_material-operation_number
IMPORTING
output = ls_material-operation_number.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_material-sequence
IMPORTING
output = ls_material-sequence.
* Begin of A236938 DV9K902864
lv_vornr = lc_vornr.
* End of A236938 DV9K902864
lv_sequence = ls_material-sequence.
lv_operation_sc = lv_vornr.
lv_sequence_sc = ls_material-sequence.
** Begin of A236938 DV9K902740
* IF ls_material-movement_type NE lc_co.
* lv_order_qty_tot_sc = lv_order_qty_tot_sc + ls_material-
order_item_quantity.
* ENDIF.
** End of A236938 DV9K902740
** Insert Component for the below type
WHEN lc_thickness.
lv_thickness = ls_char-char_value.
* Begin of A236938 DV9K902874
lv_thickness_uom = lv_thickness.
SHIFT lv_thickness_uom LEFT DELETING LEADING space.
* End of A236938 DV9K902874
* End of A236938 DV9K902740
WHEN OTHERS.
ENDCASE.
ENDLOOP.
CASE ls_material-movement_type.
WHEN lc_rm.
* begin of A236938 DV9K901707
ls_component-order_qty = ls_component-order_qty * -1.
* End of A236938 DV9K901707
* Begin of A236938 DV9K902740
* lv_order_qty_tot_sc = lv_order_qty_tot_sc + ls_material-
order_item_quantity.
* End of A236938 DV9K902740
WHEN lc_sc.
* begin of A236938 DV9K901707
ls_component-order_qty = ls_component-order_qty * -1.
* End of A236938 DV9K901707
WHEN lc_in.
* begin of A236938 DV9K901707
ls_component-order_qty = ls_component-order_qty * -1.
* End of A236938 DV9K901707
* Begin of A236938 DV9K902740
* lv_order_qty_tot_sc = lv_order_qty_tot_sc + ls_material-
order_item_quantity.
* End of A236938 DV9K902740
IF lv_length LE lc_length_val.
READ TABLE lt_zpp_wi_component INTO ls_zpp_wi_component
WITH KEY bwart = ls_material-
movement_type
family = lv_family
type = lc_sheet
BINARY SEARCH.
IF sy-subrc EQ 0.
ls_component-matnr = ls_zpp_wi_component-matnr.
ls_material-material_number = ls_zpp_wi_component-matnr.
ENDIF.
ELSE.
IF lv_width LE lc_width_val.
READ TABLE lt_zpp_wi_component INTO ls_zpp_wi_component
WITH KEY bwart = ls_material-
movement_type
family = lv_family
type = lc_strip
BINARY SEARCH.
IF sy-subrc EQ 0.
ls_component-matnr = ls_zpp_wi_component-matnr.
ls_material-material_number = ls_zpp_wi_component-matnr.
ENDIF.
ELSE.
READ TABLE lt_zpp_wi_component INTO ls_zpp_wi_component
WITH KEY bwart = ls_material-
movement_type
family = lv_family
type = lc_coil
BINARY SEARCH.
IF sy-subrc EQ 0.
ls_component-matnr = ls_zpp_wi_component-matnr.
ls_material-material_number = ls_zpp_wi_component-matnr.
ENDIF.
ENDIF.
ENDIF.
WHEN lc_co.
* Begin of A236938 DV9K902740
lv_coil_density = lv_density.
lv_coil_thickness = lv_thickness.
* Begin of A236938 DV9K902874
lv_coil_family = lv_family.
* End of A236938 DV9K902874
* End of A236938 DV9K902740
ls_component-matnr = ls_material-material_number.
* Begin of A236938 DV9K902874
* lv_order_qty_sc = lv_order_qty_sc + ls_material-
order_item_quantity.
lv_order_qty_sc = lv_order_qty_sc + ls_component-order_qty.
* End of A236938 DV9K902874
lv_family_sc = lv_family.
lv_base_unit = ls_material-base_unit_of_measure.
CALL FUNCTION 'UNIT_OF_MEASURE_ISO_TO_SAP'
EXPORTING
iso_code = lv_base_unit
IMPORTING
sap_code = lv_base_unit
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WHEN lc_fp.
* Begin of A236938 DV9K902740
* lv_order_qty_tot_sc = lv_order_qty_tot_sc + ls_material-
order_item_quantity.
* End of A236938 DV9K902740
WHEN OTHERS.
ENDCASE.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_component-matnr
IMPORTING
output = ls_component-matnr.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_material-material_number
IMPORTING
output = ls_material-material_number.
ls_component-batch = ls_material-batch_number.
ls_component-werks = ls_material-plant .
ls_component-bwart = ls_material-movement_type.
* Begin of A236938 DV9K902864
* ls_component-operation = ls_material-operation_number.
ls_component-operation = lc_vornr.
* End of A236938 DV9K902864
ls_component-sequence = ls_material-sequence.
ls_component-lgort = ls_material-storage_location.
* ls_component-order_qty = ls_material-order_item_quantity.
* ls_component-base_unit = ls_material-base_unit_of_measure.
ls_component-aposn = ls_material-position.
APPEND ls_component TO lt_component.
MODIFY lt_material FROM ls_material INDEX lv_index TRANSPORTING mate
rial_number.
REFRESH : lt_char.
CLEAR : ls_char,
ls_component,
ls_material,
* Begin of A236938 DV9K902740
lv_density,
lv_thickness.
* End of A236938 DV9K902740
ENDIF.
ENDLOOP.
* Assign Operation
ls_operation-operation = lv_vornr.
ls_operation-sequence = lv_sequence.
APPEND ls_operation TO lt_operation.
CLEAR : ls_operation.
* TRY.
CALL METHOD cl_proxy_fault=>raise
EXPORTING
exception_class_name = 'Z100217_INBOUNDCX_STANDARD_MES'
* application_log_handle =
* bapireturn_tab =
* addition =
* automatic_retry =
.
* CATCH cx_ai_application_fault .
* ENDTRY.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
FUNCTION zpp_uom_conversion.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IS_BASE_UOM) TYPE MEINS OPTIONAL
*" REFERENCE(IS_CHANGE_UOM) TYPE MEINS OPTIONAL
*" REFERENCE(IS_FAMILY) TYPE ATWRT OPTIONAL
*" REFERENCE(IS_LENGTH) TYPE ATWRT OPTIONAL
*" REFERENCE(IS_WIDTH) TYPE ATWRT OPTIONAL
*" REFERENCE(IS_THICKNESS) TYPE ATWRT OPTIONAL
*" REFERENCE(IS_ORDER_QTY) TYPE GAMNG OPTIONAL
*" EXPORTING
*" REFERENCE(EX_CHANGE_QTY) TYPE GAMNG
*"----------------------------------------------------------------------
*---------------------------------------------------------------------*
* Modification : Unit of Conversion changes
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 15/04/2016
* Reason : incident 591243
* Searchkey : DV9K902874
* Transportnumber : DV9K902874
*---------------------------------------------------------------------*
CLEAR : ls_density_tmp ,
ls_thickness_tmp,
ls_length_tmp ,
ls_width_tmp .
IF is_family EQ lc_alum.
ls_density_tmp = lc_alum_denisty.
ELSE.
ls_density_tmp = lc_denisty.
ENDIF.
ls_thickness_tmp = is_thickness .
IF ls_thickness_tmp IS INITIAL.
ls_thickness_tmp = 1.
ENDIF.
ls_length_tmp = is_length.
IF ls_length_tmp IS INITIAL.
ls_length_tmp = 1.
ENDIF.
ls_width_tmp = is_width.
IF ls_width_tmp IS INITIAL.
ls_width_tmp = 1.
ENDIF.
IF is_base_uom EQ is_change_uom.
ex_change_qty = is_order_qty.
ELSE.
CASE is_change_uom.
WHEN lc_ea.
ex_change_qty = ( ( ( ls_density_tmp ) / 1000 ) * ( ( ls_width_tmp )
/ 1000 ) * ls_thickness_tmp * ( ( ls_length_tmp ) / 1000 ) ) * is_order_qt
y .
WHEN lc_mtk.
ex_change_qty = ( ( ( ls_density_tmp ) / 1000 ) * ls_thickness_tmp )
* is_order_qty.
WHEN lc_mtr.
ex_change_qty = ( ( ( ls_density_tmp ) / 1000 ) * ( ( ls_width_tmp ) /
1000 ) * ls_thickness_tmp ) * is_order_qty.
WHEN OTHERS.
ENDCASE.
ENDIF.
ENDFUNCTION.
FUNCTION zpp_prodord_create.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IS_ORDERDATA) TYPE BAPI_PP_ORDER_CREATE
*" REFERENCE(IT_HDR_USER_STATUS) TYPE COSE_T_HDR_USER_STAT
*" OPTIONAL
*" REFERENCE(IT_SEQUENCE) TYPE COSE_T_SEQUENCE OPTIONAL
*" REFERENCE(IT_OPR_USER_STATUS) TYPE COSE_T_OPR_USER_STAT
*" OPTIONAL
*" REFERENCE(IT_COMPONENT) TYPE ZPP_T_COMPONENT OPTIONAL
*" REFERENCE(IT_OPERATION) TYPE ZPP_T_OPERATION OPTIONAL
*" REFERENCE(IT_PRODORDER) TYPE Z100217_INBOUNDSI_IA_WORK__TAB
*" OPTIONAL
*" EXPORTING
*" REFERENCE(EV_ORDER_NUMBER) LIKE BAPI_ORDER_KEY-ORDER_NUMBER
*" REFERENCE(EV_ORDER_TYPE) LIKE BAPI_ORDER_COPY-ORDER_TYPE
*" REFERENCE(ES_RETURN) LIKE BAPIRET2 STRUCTURE BAPIRET2
*" EXCEPTIONS
*" ERROR_OCCURRED
*"----------------------------------------------------------------------
*&---------------------------------------------------------------------*
* Program Description: Function module to create production order *
* *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: I_PP_002 *
* TRANSPORT NUMBER(S): DV9K900647 *
* INPUT: Production Order input data *
* Output: Generate production Order *
*----------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : This is new requirement whenever Quintiq order is create
d
* production order operation and component should be delet
ed
*
* Modified by : Bhaskar
* Date (dd-mm-yyyy): 21-03-2016
* Reason : NA
* Searchkey : DV9K902013
* Transportnumber : DV9K902013
*---------------------------------------------------------------------*
ENDFUNCTION.
*---------------------------------------------------------------------*
* Modification : {Create BDC to update Subcontracting flag for control ke
y ZPP2
* and production order user stats change to WI}
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 04-03-2016
* Reason : NA
* Searchkey :
* Transportnumber : DV9K901707
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Status Profile of production order was wrongly assigned
* Changes made to change profile from ZPP00001 to ZPP00002
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy):
* Reason : NA
* Searchkey : DV9K901978
* Transportnumber : DV9K901978
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : This is new requirement whenever Quintiq order is create
d
* production order operation and component should be delet
ed
*
* Modified by : Bhaskar
* Date (dd-mm-yyyy): 21-03-2016
* Reason : NA
* Searchkey : DV9K902013
* Transportnumber : DV9K902013
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Correct Formatting error for Percentage calculation
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 05-04-2016
* Reason : Incident 589977
* Searchkey : DV9K902620
* Transportnumber : DV9K902620
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Resolved dump in LGORT condition
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 06/04/2016
* Reason : incident 591243
* Searchkey : DV9K902677
* Transportnumber : DV9K902677
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Changes made to fix the problem of Scrap Qty
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 13/04/2016
* Reason : Incident 591243
* Searchkey : DV9K902740
* Transportnumber : DV9K902740
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Operation Number logic changed
* Modified by : Bhaskar
* Date (dd-mm-yyyy): 14-04-2016
* Reason : incident 591243
* Searchkey : DV9K902864
* Transportnumber : DV9K902864
*---------------------------------------------------------------------*
*----------------------------------------------------------------------*
***INCLUDE LZPP_PRODUCTION_ORDERF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form CREATE_PROD_ORDER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IM_ORDERDATA text
* <--P_IM_RETURN text
* <--P_EX_ORDER_NUMBER text
*----------------------------------------------------------------------*
FORM create_prod_order USING pr_im_orderdata TYPE bapi_pp_order_create
CHANGING pr_ex_return TYPE bapiret2
pr_ex_order_number TYPE aufnr.
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
CLEAR : pr_ex_return,
pr_ex_order_number.
*----------------------------------------------------------------------*
* Check input is not initial and same Order does not exist then create produc
tion order
IF pr_im_orderdata IS NOT INITIAL AND gt_header IS INITIAL.
* BAPI Create Production Order
CALL FUNCTION 'BAPI_PRODORD_CREATE'
EXPORTING
orderdata = pr_im_orderdata
IMPORTING
return = pr_ex_return
order_number = pr_ex_order_number.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
CLEAR : pr_ex_return.
* Commit Data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = pr_ex_return.
WAIT UP TO 5 SECONDS.
ELSE.
* Data Rollback
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
RAISE error_occurred.
ENDIF.
ELSE.
pr_ex_order_number = pr_im_orderdata-order_number.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form RELEASE_PROD_ORDER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PR_EX_ORDER_NUMBER text
* -->PR_IM_ORDERDATA text
* <--PR_EX_RETURN text
*----------------------------------------------------------------------*
FORM release_prod_order USING pr_ex_order_number TYPE aufnr
pr_im_orderdata TYPE bapi_pp_order_create
CHANGING pr_ex_return TYPE bapiret2.
*-----------L O C A L D A T A D E C L A R A T I O N--------------*
DATA :lt_order TYPE STANDARD TABLE OF bapi_order_key INITIAL SIZE 0,
ls_order TYPE bapi_order_key,
lv_objnr TYPE j_objnr,
lv_objnr_jest TYPE j_objnr,
lv_stat TYPE j_status,
lv_release_flag TYPE flag.
*----------------------------------------------------------------------*
*-----------L O C A L C O N S T A N T D E C L A R A T I O N----------*
CONSTANTS : lc_release TYPE j_status VALUE 'I0002'.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lt_order.
CLEAR :ls_order,
lv_objnr,
lv_objnr_jest,
lv_stat,
lv_release_flag .
*----------------------------------------------------------------------*
ls_order-order_number = pr_ex_order_number.
APPEND ls_order TO lt_order.
CLEAR : ls_order.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
CLEAR : pr_ex_return.
* Commit Data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = pr_ex_return.
ELSE.
* Data Rollback
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
RAISE error_occurred.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_OPER_PROD_ORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PR_EX_ORDER_NUMBER text
* -->PR_IM_ORDERDATA text
* -->PR_IM_SEQUENCE text
* -->PR_IM_OPERATION text
* <--PR_EX_RETURN text
*----------------------------------------------------------------------*
FORM add_oper_prod_ord USING pr_ex_order_number TYPE aufnr
pr_im_orderdata TYPE bapi_pp_order_create
pr_im_sequence TYPE cose_t_sequence
pr_im_operation TYPE zpp_t_operation
pr_im_hdr_user_status TYPE cose_t_hdr_user_st
at
pr_im_opr_user_status TYPE cose_t_opr_user_st
at
CHANGING pr_ex_return TYPE bapiret2.
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : lt_operation TYPE STANDARD TABLE OF cose_s_operation INITIAL SIZ
E 0,
ls_operation TYPE cose_s_operation,
ls_p_im_operation TYPE zpp_s_operation,
lt_p_im_operation TYPE zpp_t_operation,
lv_ekgrp TYPE ekgrp,
lv_matkl TYPE matkl,
lt_opr_del TYPE cose_t_opr_delete,
ls_opr_del TYPE cose_s_opr_delete.
*----------------------------------------------------------------------*
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------*
CONSTANTS : lc_zpp2 TYPE steus VALUE 'ZPP2',
lc_scdummy(7) TYPE c VALUE 'SCDUMMY',
lc_vornr TYPE vornr VALUE '0001'.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lt_operation,
lt_p_im_operation,
lt_opr_del.
CLEAR : ls_p_im_operation,
lv_ekgrp,
lv_matkl,
ls_opr_del.
*----------------------------------------------------------------------*
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
lt_p_im_operation[] = pr_im_operation[].
ENDIF.
* Check the duplicate data and discard it
IF gt_operation IS NOT INITIAL.
LOOP AT gt_operation INTO gs_operation.
READ TABLE lt_p_im_operation INTO ls_p_im_operation WITH KEY operation
= gs_operation-operation_number
sequence =
gs_operation-sequence_no
BINARY SEA
RCH.
IF sy-subrc EQ 0.
* if data found then discard it
DELETE lt_p_im_operation WHERE operation EQ ls_p_im_operation-
operation.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
CLEAR : pr_ex_return.
* Commit Data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = pr_ex_return.
WAIT UP TO 2 SECONDS.
ls_opr_del-vornr = lc_vornr.
APPEND ls_opr_del TO lt_opr_del.
CLEAR : ls_opr_del.
ELSE.
* Data Rollback
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
RAISE error_occurred.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_COMPONENT_PROD_ORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_EX_ORDER_NUMBER text
* <--P_EX_RETURN text
*----------------------------------------------------------------------*
FORM add_component_prod_ord USING pr_ex_order_number TYPE aufnr
pr_im_component TYPE zpp_t_component
CHANGING pr_ex_return TYPE bapiret2.
*-----------L O C A L T Y P E S D E C L A R A T I O N---------------*
TYPES : BEGIN OF lty_quantity,
quantity LIKE afko-gamng,
uom LIKE afko-gmein,
END OF lty_quantity.
TYPES : BEGIN OF lty_afko,
aufnr TYPE aufnr,
aufpl TYPE co_aufpl,
END OF lty_afko.
*----------------------------------------------------------------------*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : ls_quantity TYPE lty_quantity,
lv_operation TYPE co_aplzl,
lv_sequence TYPE plnfolge,
lv_lgortx TYPE flag,
lv_batchx TYPE flag,
lv_positionno TYPE positionno,
lv_error TYPE flag,
ls_p_im_component TYPE zpp_s_component,
lt_p_im_component TYPE STANDARD TABLE OF zpp_s_component INITIAL SIZE
0,
ls_lgort TYPE coxt_s_storage_location,
ls_lgortx TYPE coxt_s_storage_locationx,
lt_afko TYPE STANDARD TABLE OF lty_afko INITIAL SIZE 0,
ls_afko TYPE lty_afko,
lt_afvc TYPE STANDARD TABLE OF lty_afvc INITIAL SIZE 0,
ls_afvc TYPE lty_afvc.
*----------------------------------------------------------------------*
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------*
CONSTANTS :lc_postp TYPE postp VALUE 'L'.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lt_p_im_component,
lt_afko,
lt_afvc.
CLEAR : ls_quantity,
lv_operation,
lv_sequence,
lv_lgortx,
lv_batchx,
lv_positionno,
lv_error,
ls_p_im_component,
ls_lgort,
ls_lgortx,
ls_afvc,
ls_afko.
*----------------------------------------------------------------------*
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
ENDIF.
ENDIF.
lt_p_im_component[] = pr_im_component[].
SORT lt_p_im_component BY aposn.
lv_operation = ls_afvc-aplzl.
lv_sequence = ls_afvc-plnfl.
LOOP AT lt_p_im_component INTO ls_p_im_component.
* lv_positionno = lv_positionno + 10.
lv_positionno = ls_p_im_component-aposn.
ls_quantity-quantity = ls_p_im_component-order_qty.
ls_quantity-uom = ls_p_im_component-base_unit.
* Begin of A236938 DV9K902677
IF ls_p_im_component-lgort IS INITIAL.
* IF ls_p_im_component-lgort EQ 0.
* Begin of A236938 DV9K902677
ls_p_im_component-lgort = space.
ENDIF.
IF ls_p_im_component-lgort IS NOT INITIAL.
ls_lgort-lgort = ls_p_im_component-lgort.
ls_lgortx-lgort = abap_true.
ELSE.
ls_lgort-lgort = space.
ls_lgortx-lgort = abap_false.
ENDIF.
ELSE.
CLEAR : lv_error.
* Commit transaction
CALL FUNCTION 'CO_XT_ORDER_PREPARE_COMMIT'
IMPORTING
es_bapireturn = pr_ex_return
e_error_occurred = lv_error.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL .
CLEAR : pr_ex_return.
* Commit Data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = pr_ex_return.
CALL FUNCTION 'CO_XT_ORDER_INITIALIZE'.
ELSE.
* Data Rollback
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
RAISE error_occurred.
EXIT.
ENDIF.
ENDIF.
CLEAR : lv_error,
lv_operation,
lv_sequence,
ls_quantity,
lv_lgortx,
lv_batchx.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_PROD_ORDER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PR_IM_ORDERDATA text
* <--PR_EX_RETURN text
*----------------------------------------------------------------------*
FORM get_prod_order USING pr_im_orderdata TYPE bapi_pp_order_create.
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
CLEAR : gs_order_objects,
lv_aufnr..
REFRESH : gt_header,
gt_sequence,
gt_operation,
gt_component.
*----------------------------------------------------------------------*
IF pr_im_orderdata-order_number IS NOT INITIAL.
* Check Production order already exist or not
lv_aufnr = pr_im_orderdata.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_aufnr
IMPORTING
output = lv_aufnr.
gs_order_objects-header = abap_true.
gs_order_objects-positions = abap_true.
gs_order_objects-sequences = abap_true.
gs_order_objects-operations = abap_true.
gs_order_objects-components = abap_true.
* get production order data
CALL FUNCTION 'BAPI_PRODORD_GET_DETAIL'
EXPORTING
number = lv_aufnr
order_objects = gs_order_objects
IMPORTING
return = ls_return
TABLES
header = gt_header
sequence = gt_sequence
operation = gt_operation
component = gt_component.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form UPDATE_LINE_ITEM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PR_P_EX_ORDER_NUMBER text
* -->PR_LT_P_IM_COMPONENT[] text
* <--PR_P_EX_RETURN text
*----------------------------------------------------------------------*
FORM update_line_item USING pr_p_ex_order_number TYPE aufnr
pr_lt_p_im_component TYPE zpp_t_component
CHANGING pr_p_ex_return TYPE bapiret2.
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------------
--*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : ls_order_objects TYPE bapi_pp_order_objects,
lt_component TYPE STANDARD TABLE OF bapi_order_component
INITIAL SIZE 0,
wa_component TYPE bapi_order_component,
ls_p_lt_p_im_component TYPE zpp_s_component,
ls_messtab TYPE bdcmsgcoll.
DATA : ls_return TYPE bapiret2,
lv_count TYPE sy-tabix,
lv_fname TYPE dynfnam,
lc_cnt(2) TYPE n,
lv_tabix TYPE sy-tabix,
lv_count_compo TYPE sy-tabix.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
CLEAR : ls_order_objects,
ls_p_lt_p_im_component,
lv_count.
CLEAR : ls_return,
lv_fname,
lc_cnt,
lv_tabix,
lv_count_compo,
ls_messtab.
REFRESH: gt_bdcdata,
gt_messtab.
REFRESH : lt_component.
*----------------------------------------------------------------------*
IF ( pr_p_ex_return-type EQ gc_success OR
pr_p_ex_return-type EQ gc_warn OR
pr_p_ex_return-type EQ gc_info ) OR
pr_p_ex_return IS INITIAL.
lv_tabix = sy-tabix.
IF lv_tabix EQ 1.
PERFORM f_bdc_dynpro USING 'SAPLCOMK' '0120'.
PERFORM f_bdc_field USING 'BDC_CURSOR'
lv_fname.
PERFORM f_bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM f_bdc_field USING 'FILTER_BOX'
'NO_FIL'.
lc_cnt = lc_cnt + 1.
IF lv_tabix GE lv_count.
EXIT.
ENDIF.
ENDLOOP.
CLEAR : lv_tabix.
LOOP AT pr_lt_p_im_component INTO ls_p_lt_p_im_component .
lv_tabix = sy-tabix.
* IF lv_tabix EQ 1.
PERFORM f_bdc_dynpro USING 'SAPLCOMD' '0110'.
PERFORM f_bdc_field USING 'BDC_SUBSCR'
'SAPLCOKO1
0800ORD_HEADER'.
PERFORM f_bdc_field USING 'BDC_SUBSCR'
'SAPLCOMD
0100SUBSCR_0100'.
* ENDIF.
ENDLOOP.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM f_bdc_dynpro USING pu_program pu_dynpro.
gs_bdcdata-program = pu_program.
gs_bdcdata-dynpro = pu_dynpro.
gs_bdcdata-dynbegin = abap_true.
APPEND gs_bdcdata TO gt_bdcdata.
CLEAR gs_bdcdata.
ENDFORM. "f_BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM f_bdc_field USING pu_fnam pu_fval.
gs_bdcdata-fnam = pu_fnam.
gs_bdcdata-fval = pu_fval.
APPEND gs_bdcdata TO gt_bdcdata.
CLEAR gs_bdcdata.
ENDFORM. "f_bdc_field
*&---------------------------------------------------------------------*
*& Form CREATE_SETTLEMENT_RULE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IS_ORDERDATA text
* <--P_ES_RETURN text
*----------------------------------------------------------------------*
FORM create_settlement_rule USING pr_is_orderdata TYPE bapi_pp_order_creat
e
pr_it_prodorder TYPE z100217_inboundsi_i
a_work__tab
CHANGING pr_ex_return TYPE bapiret2.
*-----------L O C A L C O N S T A N T D E C L A R A T I O N----------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
CLEAR : lv_objnr,
lv_flag,
lv_aufnr.
*----------------------------------------------------------------------*
lv_aufnr = pr_is_orderdata-order_number.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
IF lv_flag EQ abap_true.
PERFORM create_settlement USING pr_is_orderdata
pr_it_prodorder[]
CHANGING pr_ex_return .
ELSE.
RAISE error_occurred.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_SETTLEMENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PR_IS_ORDERDATA text
* <--P_PR_ES_RETURN text
*----------------------------------------------------------------------*
FORM create_settlement USING pr_pr_is_orderdata TYPE bapi_pp_order_create
pr_pr_it_prodorder TYPE z100217_inboundsi_ia_
work__tab
CHANGING pr_pr_es_return TYPE bapiret2.
*-----------L O C A L T Y P E S D E C L A R A T I O N-----------------*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
*-----------L O C A L C O N S T A N T D E C L A R A T I O N----------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lt_settle,
gt_bdcdata,
gt_messtab.
CLEAR : ls_prodorder,
ls_settle,
gs_bdcdata,
lv_cnt,
lv_ord_qty,
lv_konty,
lv_empge,
lv_prozs,
lv_perbz,
lv_extnr,
lv_tabix,
ls_messtab,
* Begin of A236938 DV9K902740
lv_count,
lv_prozs_tmp.
* End of A236938 DV9K902740
*----------------------------------------------------------------------*
LOOP AT pr_pr_it_prodorder INTO ls_prodorder.
lv_ord_qty = lv_ord_qty + ls_prodorder-order_item_quantity.
ENDLOOP.
CLEAR : lv_cnt.
MOVE 1 TO lv_cnt.
IF lv_tabix EQ 1.
PERFORM f_bdc_dynpro USING 'SAPLKOBS' '0130'.
PERFORM f_bdc_field USING 'BDC_CURSOR'
lv_konty.
PERFORM f_bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM f_bdc_field USING 'BDC_SUBSCR'
'SAPLKOBS
0200BLOCK1'.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form RELEASE_ORIGINAL_PROD_ORDER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IS_ORDERDATA text
* -->P_IT_PRODORDER[] text
* <--P_ES_RETURN text
*----------------------------------------------------------------------*
FORM release_original_prod_order USING pr_is_orderdata TYPE bapi_pp_order_
create
pr_it_prodorder TYPE z100217_inboun
dsi_ia_work__tab
CHANGING pr_ex_return TYPE bapiret2.
*-----------L O C A L T Y P E S D E C L A R A T I O N--------------*
*----------------------------------------------------------------------*
*-----------L O C A L D A T A D E C L A R A T I O N--------------*
DATA :lt_order TYPE STANDARD TABLE OF bapi_order_key INITIAL SIZE 0,
ls_order TYPE bapi_order_key,
lt_objnr TYPE STANDARD TABLE OF lty_objnr INITIAL SIZE 0,
ls_objnr TYPE lty_objnr,
lt_jest TYPE STANDARD TABLE OF lty_jest INITIAL SIZE 0,
ls_jest TYPE lty_jest,
lt_order_tmp TYPE z100217_inboundsi_ia_work__tab,
ls_order_tmp TYPE z100217_inboundsi_ia_work_ins2,
lv_index TYPE sy-tabix.
*-----------L O C A L C O N S T A N T D E C L A R A T I O N----------*
CONSTANTS : lc_release TYPE j_status VALUE 'I0002',
* begin of DV9K901977
lc_status_profile TYPE co_stsma_hdr VALUE 'ZPP00002',
* End of DV9K901977
lc_status TYPE p_txt04 VALUE 'WI',
lc_delete TYPE j_status VALUE 'I0013',
lc_sign TYPE c VALUE 'I',
lc_option(2) TYPE c VALUE 'EQ'.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lt_order,
lt_objnr,
lt_jest,
lt_order_tmp,
lr_stat.
CLEAR : ls_order,
ls_objnr,
ls_jest,
ls_order_tmp,
lv_index,
ls_stat.
*----------------------------------------------------------------------*
ls_stat-sign = lc_sign.
ls_stat-option = lc_option.
ls_stat-low = lc_release.
APPEND ls_stat TO lr_stat.
CLEAR : ls_stat.
ls_stat-sign = lc_sign.
ls_stat-option = lc_option.
ls_stat-low = lc_delete.
APPEND ls_stat TO lr_stat.
CLEAR : ls_stat.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
CLEAR : pr_ex_return.
* Commit Data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = pr_ex_return.
* Begin of A236938 DV9K901707
WAIT UP TO 2 SECONDS.
* Set Order Status as WI
CALL FUNCTION 'BAPI_PRODORD_SETUSERSTATUS'
EXPORTING
status_profile = lc_status_profile
status = lc_status
IMPORTING
return = pr_ex_return
TABLES
orders = lt_order.
IF ( pr_it_prodorder IS NOT INITIAL AND
( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL ).
* Commit Data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = pr_ex_return.
ELSE.
* Data Rollback
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
RAISE error_occurred.
ENDIF.
* End of A236938 DV9K901707
ELSE.
* Data Rollback
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
RAISE error_occurred.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form UPDATE_SUBCONTRACTING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PR_IM_OPERATION text
* -->P_PR_EX_ORDER_NUMBER text
*----------------------------------------------------------------------*
* Begin of A236938 DV9K901707
REFRESH : gt_bdcdata,
gt_messtab.
CLEAR : gs_bdcdata,
ls_messtab,
lv_vornr,
lv_cnt.
MOVE 1 TO lv_cnt.
CONCATENATE 'AFVGD-VORNR('lv_cnt')' INTO lv_vornr.
ENDIF.
REFRESH : gt_bdcdata,
gt_messtab.
CLEAR : gs_bdcdata,
ls_messtab,
lv_vornr,
lv_cnt.
ENDFORM.
REFRESH : lt_afko,
lt_afvc,
lt_jest,
lt_order.
CLEAR : ls_afko,
ls_afvc,
ls_it_prodorder,
ls_jest,
ls_order,
lv_index,
lv_vornr.
ENDLOOP.
SELECT aufnr
aufpl
FROM afko INTO TABLE lt_afko
FOR ALL ENTRIES IN lt_order
WHERE aufnr EQ lt_order-order_number.
IF sy-subrc EQ 0.
SORT lt_afko BY aufnr .
SELECT aufpl
vornr
objnr
FROM afvc INTO TABLE lt_afvc
FOR ALL ENTRIES IN lt_afko
WHERE aufpl EQ lt_afko-aufpl.
IF sy-subrc EQ 0.
SORT lt_afvc BY aufpl vornr.
SELECT objnr
stat
FROM jest INTO TABLE lt_jest
FOR ALL ENTRIES IN lt_afvc
WHERE objnr EQ lt_afvc-objnr
AND inact EQ abap_false
AND stat EQ lc_delete.
IF sy-subrc EQ 0.
SORT lt_jest BY objnr stat.
ENDIF.
ENDIF.
ENDIF.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
CLEAR : pr_ex_return.
ls_opr_del-vornr = ls_it_prodorder-operation_number.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_opr_del-vornr
IMPORTING
output = ls_opr_del-vornr.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
CLEAR : pr_ex_return.
* Commit Data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = pr_ex_return.
WAIT UP TO 2 SECONDS.
ENDIF.
ENDIF.
ELSE.
ls_operation-sequence = lc_plnfl.
ls_operation-operation = lc_vornr.
ls_operation-control_key = lc_zpp1.
ls_operation-short_text = lc_shorttext.
ls_operation-short_text_x = abap_true.
APPEND ls_operation TO lt_operation.
CLEAR : ls_operation.
ls_opr_del-vornr = ls_it_prodorder-operation_number.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_opr_del-vornr
IMPORTING
output = ls_opr_del-vornr.
APPEND ls_opr_del TO lt_opr_del.
CLEAR : ls_opr_del.
IF ( pr_ex_return-type EQ gc_success OR
pr_ex_return-type EQ gc_warn OR
pr_ex_return-type EQ gc_info ) OR
pr_ex_return IS INITIAL.
CLEAR : pr_ex_return.
* Commit Data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = pr_ex_return.
WAIT UP TO 2 SECONDS.
* ENDIF.
* ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
REFRESH : lt_opr_del,
lt_operation.
ENDLOOP.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
* Program Description: This function module is used to update all *
* errors details through interface/enhancement *
* DEVELOPER: Surajit Dubey *
* CREATION DATE: 14/12/2015 *
* OBJECT NUMBER: N/A *
* TRANSPORT NUMBER(S): DV9K900347 *
* INPUT: I_EXTNUMBER will be XX.Y.ZZZZ format *
* Details are shown in the FM documentation *
* Output: Update Application log for ZCA_ERROR *
*----------------------------------------------------------------------*
FUNCTION zca_error_log_upd.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_EXTNUMBER) TYPE CHAR9
*" VALUE(I_LOG_MESSAGE) TYPE ZCA_T_ERROR_LOG_STRUC
*" EXCEPTIONS
*" LOG_HEADER_INCONSISTENT
*" LOGGING_ERROR
*" LOG_NOT_FOUND
*" MSG_INCONSISTENT
*" LOG_IS_FULL
*" SAVE_NOT_ALLOWED
*" NUMBERING_ERROR
*" FORMAT_CHECK
*" BLANK_ERROR_LOG
*"----------------------------------------------------------------------
*----------------------------------------------------------------------*
* D A T A D E C L A R A T I O N
*
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*M A I N P R O C E S S I N G
*
*----------------------------------------------------------------------*
lv_s_log-object = lc_log_object.
lv_ext_no = i_extnumber.
lv_s_log-extnumber = lv_ext_no.
ls_mdef-log_handle = lv_log_handle.
ls_msg-msgty = ls_log_message-msgty.
ls_msg-msgid = ls_log_message-msgid.
ls_msg-msgno = ls_log_message-msgno.
ls_msg-msgv1 = ls_log_message-msgv1.
ls_msg-msgv2 = ls_log_message-msgv2.
ls_msg-msgv3 = ls_log_message-msgv3.
ls_msg-msgv4 = ls_log_message-msgv4.
IF sy-subrc EQ 0.
APPEND lv_log_handle TO lt_log_handle.
* Update the database table for application log
CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
i_t_log_handle = lt_log_handle
EXCEPTIONS
log_not_found = 1
save_not_allowed = 2
numbering_error = 3
OTHERS = 4.
IF sy-subrc EQ 0.
* Update the database
COMMIT WORK.
ELSE.
CASE sy-subrc.
WHEN 1.
RAISE log_not_found.
WHEN 2.
RAISE save_not_allowed.
WHEN 3.
RAISE numbering_error.
WHEN 4.
RAISE logging_error.
ENDCASE.
ENDIF.
ELSE.
CASE sy-subrc.
WHEN 1.
RAISE log_not_found.
WHEN 2.
RAISE msg_inconsistent.
WHEN 3.
RAISE log_is_full.
WHEN 4.
RAISE logging_error.
ENDCASE.
ENDIF.
ENDLOOP.
ELSE.
CASE sy-subrc .
WHEN 1.
RAISE logging_error.
ENDCASE.
ENDIF.
ELSE.
CASE sy-subrc .
WHEN 1.
RAISE log_header_inconsistent.
WHEN 2.
RAISE logging_error.
ENDCASE.
ENDIF.
ELSE.
RAISE blank_error_log.
ENDIF.
ENDFUNCTION.
=============================================================================
*&---------------------------------------------------------------------*
*& Include ZI_PP_PROD_ORDR_SEND_QUINTIQ
*&---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : {To trigger IDOC for production order from Sales Order
* program RCCLORD is called. in Production Order
* there is no o/p type concept for IDOC trigger.
* We have tried Event but that is also not working as req
uirement is
* to trigger IDOC when Prod created or change }
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 10-03-2016
* Reason : NA
* Searchkey : DV9K901857
* Transportnumber : DV9K901857
*---------------------------------------------------------------------*
* REVISION HISTORY-----------------------------------------------------*
* REVISION NO: 1. REFERENCE NO: Ticket 594623 *
* DEVELOPER : Arunodaya Biswas *
* TRANSPORT : DV9K902949 *
* DESCRIPTION: Implement Wait for database commit *
* DATE : 20.04.2016 *
* SEARCH KEY : T_594623 *
*&---------------------------------------------------------------------*
*------------L O C A L T Y P E S I N I T I A L L Z A T I O N------------
-*
TYPES : BEGIN OF lty_aufnr,
sign TYPE c LENGTH 1,
option TYPE c LENGTH 2,
low TYPE aufnr,
high TYPE aufnr,
END OF lty_aufnr.
*-------L O C A L D A T A D E C L A R A T I O N----------------------*
DATA : lt_aufnr TYPE STANDARD TABLE OF lty_aufnr INITIAL SIZE 0,
lwa_aufnr TYPE lty_aufnr,
lt_werks TYPE STANDARD TABLE OF lty_werks INITIAL SIZE 0,
lwa_werks TYPE lty_werks,
lt_matnr TYPE STANDARD TABLE OF lty_matnr,
lwa_matnr TYPE lty_matnr,
lv_logsys TYPE logsys.
*-------------------C O N S T A N T D E C L A R A T I O N------------*
CONSTANTS : lc_sign(1) TYPE c VALUE 'I',
lc_option(2) TYPE c VALUE 'EQ',
lc_dev TYPE logsys VALUE 'SAPPID',
lc_test TYPE logsys VALUE 'SAPPIQ',
lc_prod TYPE logsys VALUE 'SAPPIP',
lc_mestyp TYPE edi_mestyp VALUE 'ZLOIPRO_100216',
lc_auart TYPE auart VALUE 'ZPN1',
lc_dv9 TYPE sysid VALUE 'DV9',
lc_ts9 TYPE sysid VALUE 'TS9',
lc_pr9 TYPE sysid VALUE 'PR9',
lc_zpc1 TYPE auart VALUE 'ZPC1'.
*------------------D A T A I N I T I A L L Z A T I O N-----------------*
REFRESH : lt_aufnr,
lt_werks.
CLEAR : lwa_aufnr,
lwa_werks,
lv_logsys.
CLEAR : gs_caufvd.
*-------------------------------------------------------------------------*
WAIT UP TO 5 SECONDS."++T_594623
IMPORT gs_caufvd FROM MEMORY ID 'PRODORD'.
*-------------------------------------------------------------------------*
IF gs_caufvd-auart EQ lc_auart.
IF sy-sysid EQ lc_dv9.
lv_logsys = lc_dev.
ELSEIF sy-sysid EQ lc_ts9.
lv_logsys = lc_test.
ELSEIF sy-sysid EQ lc_pr9.
lv_logsys = lc_prod.
ELSE.
lv_logsys = space.
ENDIF.
CLEAR : lwa_aufnr,
lwa_werks,
lv_logsys.
CLEAR : gs_caufvd.
ENDIF.
====================================================================
*----------------------------------------------------------------------*
***INCLUDE ZXCO1F01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Program Description: Function module to create production order *
* *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: I_PP_002 *
* TRANSPORT NUMBER(S): DV9K900647 *
* INPUT: Production Order input data *
* Output: Generate production Order *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form INIT_AND_FILL_TREE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM init_and_fill_tree .
gv_repid = sy-repid.
* Create Object for tree
CREATE OBJECT co_tree1
EXPORTING
parent = customcontainer
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
with_headers = ' '
EXCEPTIONS
cntl_system_error = 1
create_error = 2
failed = 3
illegal_node_selection_mode = 4
lifetime_error = 5.
IF sy-subrc <> 0.
* error handling
ENDIF.
** Register Event
CALL METHOD co_tree1->set_registered_events
EXPORTING
events = gt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
** error handling
ENDIF.
* Create Event handler object
CREATE OBJECT gr_event_handler.
ENDFORM.
FORM build_node_and_item_table.
*-----------L O C A L T Y P E S D E C L A R A T I O N-----------------*
*-----------L O C A L D A T A D E C L A R A T I O N----------------------*
*-----------L O C A L F I E L D S Y M B O L D E C L A R A T I O N--------
--------------*
FIELD-SYMBOLS : <lf_zpp_rel_wi_op_data> TYPE lty_zpp_rel_wi_op.
*----------------------------------------------------------------------*
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------*
CONSTANTS : lc_zpc1 TYPE aufart VALUE 'ZPC1',
lc_one(1) TYPE c VALUE '1',
lc_size(2) TYPE c VALUE '12'.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
CLEAR : ls_node,
ls_item,
ls_zpp_rel_wi_op,
gs_caufvd,
lv_auart,
lv_aufnr_tmp,
ls_node_aufnr,
ls_zpp_rel_wi_op_ref,
ls_zpp_rel_wi_op_ref_data,
ls_zpp_rel_wi_op_data,
ls_node_aufnr_main,
lv_node_key,
lv_node_parent,
ls_reln,
lv_root_aufnr,
ls_reln_tmp,
gs_item_table.
REFRESH :lt_zpp_rel_wi_op,
lt_zpp_rel_wi_op_tmp,
lt_zpp_rel_wi_op_tmp1,
lt_node_aufnr,
lt_zpp_rel_wi_op_ref,
lt_zpp_rel_wi_op_ref_data,
lt_zpp_rel_wi_op_data,
lt_node_aufnr_main,
lt_zpp_rel_wi_op_ref1,
lt_treev_nks,
lt_reln,
gt_node_table,
gt_item_table.
*----------------------------------------------------------------------*
WHEN OTHERS.
SELECT aufnr
paufnr
wi_post
final
FROM zpp_rel_wi_op
INTO TABLE lt_zpp_rel_wi_op
WHERE paufnr EQ gs_caufvd-aufnr .
IF sy-subrc EQ 0.
SORT lt_zpp_rel_wi_op BY aufnr paufnr.
ENDIF.
ENDCASE.
ENDIF.
SELECT aufnr
paufnr
wi_post
final
FROM zpp_rel_wi_op
INTO TABLE lt_zpp_rel_wi_op_data
FOR ALL ENTRIES IN lt_zpp_rel_wi_op_tmp1
WHERE aufnr EQ lt_zpp_rel_wi_op_tmp1-aufnr .
IF sy-subrc EQ 0.
SORT lt_zpp_rel_wi_op_data BY aufnr.
ENDIF.
SELECT aufnr
paufnr
wi_post
final
FROM zpp_rel_wi_op
INTO TABLE lt_zpp_rel_wi_op_ref
FOR ALL ENTRIES IN lt_zpp_rel_wi_op_tmp1
WHERE wi_post EQ lt_zpp_rel_wi_op_tmp1-aufnr .
IF sy-subrc EQ 0.
lt_zpp_rel_wi_op_ref1[] = lt_zpp_rel_wi_op_ref[].
SORT lt_zpp_rel_wi_op_ref1 BY wi_post paufnr.
SORT lt_zpp_rel_wi_op_ref BY aufnr.
DELETE ADJACENT DUPLICATES FROM lt_zpp_rel_wi_op_ref COMPARING a
ufnr.
SELECT aufnr
paufnr
wi_post
final
FROM zpp_rel_wi_op
INTO TABLE lt_zpp_rel_wi_op_ref_data
FOR ALL ENTRIES IN lt_zpp_rel_wi_op_ref
WHERE aufnr EQ lt_zpp_rel_wi_op_ref-aufnr .
IF sy-subrc EQ 0.
SORT lt_zpp_rel_wi_op_ref_data BY wi_post.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
AT NEW aufnr.
ls_node_aufnr-aufnr = <lf_zpp_rel_wi_op_data>-aufnr.
ls_node_aufnr-folder = abap_true.
ls_node_aufnr-root_aufnr = space.
APPEND ls_node_aufnr TO lt_node_aufnr.
CLEAR : ls_node_aufnr.
ENDAT.
ELSE.
ls_node_aufnr-aufnr = <lf_zpp_rel_wi_op_data>-paufnr.
ls_node_aufnr-folder = space.
ls_node_aufnr-root_aufnr = <lf_zpp_rel_wi_op_data>-aufnr.
APPEND ls_node_aufnr TO lt_node_aufnr.
CLEAR : ls_node_aufnr.
ENDIF.
ENDLOOP.
ENDIF.
ls_reln-node = lv_node_key.
ls_reln-folder = ls_node_aufnr-folder.
ls_reln-aufnr = ls_node_aufnr-aufnr.
lv_node_parent = lv_node_key.
ls_reln-parent = lv_node_parent.
ADD 1 TO lv_node_key.
*----------------------------------------------------------------------*
***INCLUDE ZXCO1O01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Program Description: Function module to create production order *
* *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: I_PP_002 *
* TRANSPORT NUMBER(S): DV9K900647 *
* INPUT: Production Order input data *
* Output: Generate production Order *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
IF gv_init IS INITIAL .
* Create Node Tree
PERFORM init_and_fill_tree.
gv_init = 'X'.
* ELSE.
* CALL METHOD tree->delete_all_nodes
* EXCEPTIONS
* failed = 1
* cntl_system_error = 2
* OTHERS = 3.
*
* CALL METHOD tree->add_nodes_and_items
* EXPORTING
* node_table = gt_node_table
* item_table = gt_item_table
* item_table_structure_name = 'MTREEITM'
* EXCEPTIONS
* failed = 1
* cntl_system_error = 2
* error_in_tables = 3
* dp_error = 4
* table_structure_name_not_found = 5
* OTHERS = 6.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*
*
*
* ENDIF.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
*----------------------------------------------------------------------*
***INCLUDE ZXCO1TOP.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Program Description: Function module to create production order *
* *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: I_PP_002 *
* TRANSPORT NUMBER(S): DV9K900647 *
* INPUT: Production Order input data *
* Output: Generate production Order *
*----------------------------------------------------------------------*
*-----------------T Y P E S D E C L A R A T I O N--------------------------
---*
*-----------------D A T A D E C L A R A T I O N-----------------------------
----*
*----------------------------------------------------------------------------
----*
*-----------------C L A S S D E C L A R A T I O N---------------------------
------*
* Define Class
CLASS cl_gui_cfw DEFINITION LOAD.
*-----------------D A T A D E C L A R A T I O N-----------------------------
----*
DATA : customcontainer TYPE REF TO cl_gui_custom_container, "Define Custom
Container
gt_events TYPE cntl_simple_events, "Evenet
gs_event TYPE cntl_simple_event, "Event work are
a
gv_repid LIKE sy-repid, "report
Name
gt_node_table TYPE treev_ntab, "Node Table
gt_node_table_tmp TYPE treev_ntab, "Node Table
gs_h_header TYPE treev_hhdr,
co_tree1 TYPE REF TO cl_gui_list_tree. "Define Tree.
"Tree Header
* You should create your own structure in dictionary to define the
* item_table
DATA : gt_item_table LIKE STANDARD TABLE OF mtreeitm,
gs_item_table TYPE mtreeitm,
gt_item_table_tmp LIKE STANDARD TABLE OF mtreeitm.
*----------------------------------------------------------------------------
----*
*-----------------C L A S S I M P L E M E N T A T I O N---------------------
-----*
* CLASS_FINAL
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS
constructor.
METHODS
handle_item_double_click
FOR EVENT item_double_click
OF cl_gui_list_tree
IMPORTING node_key item_name .
ENDCLASS.
*----------------------------------------------------------------------------
----*
* Event Handler
DATA gr_event_handler TYPE REF TO lcl_event_handler.
*-----------------M E T H O D D E F I N I T I O N---------------------------
-----*
* Event handling module
MODULE event_handling INPUT.
CALL METHOD cl_gui_cfw=>dispatch
IMPORTING
return_code = gv_rc.
ENDMODULE. " EVENT_HANDLING INPUT
*-----------------E V E N T I M P L E M E N T A T I O N--------------------
---------*
* Event handler implementation
CLASS lcl_event_handler IMPLEMENTATION.
##NEEDED
METHOD constructor.
ENDMETHOD.
* Handle Double Click Event
METHOD handle_item_double_click.
* Call CO03
READ TABLE gt_item_table INTO gs_item_table WITH KEY node_key = node_key.
IF sy-subrc EQ 0.
SET PARAMETER ID 'ANR' FIELD gs_item_table-text.
CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD.
ENDCLASS.
*&---------------------------------------------------------------------*
*& Include ZXCO1U11
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Program Description: Function module to create production order *
* *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: I_PP_002 *
* TRANSPORT NUMBER(S): DV9K900647 *
* INPUT: Production Order input data *
* Output: Generate production Order *
*----------------------------------------------------------------------*
***INCLUDE ZXLOIF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Program Description: USER EXIT to Assign values to custom segment *
* for Production order SAP to QUINTIQ *
* *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: *
* TRANSPORT NUMBER(S): DV9K900575 *
*----------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Open Qunatity having negative singn at the end
* which fails in Quintiq. changes made in code to put
* minus sign at the front
* Modified by : Bhaskar
* Date (dd-mm-yyyy): 21-03-2016
* Reason : NA
* Searchkey : DV9K902013
* Transportnumber : DV9K902013
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : name of the Characteristic OUTER_DIAMETER_MAX and
* OUTER_DIAMETER_MIN is changed to OUTER_MIN_DIAMTER
* and OUTER_MAX_DIAMTER
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 23-03-2016
* Reason : NA
* Searchkey : DV9K902228
* Transportnumber : DV9K902228
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Goods Issue Date is wrongly mapped
* Goods issue date is fetched from VBEP-WADAT
*
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 23-03-2016
* Reason : NA
* Searchkey : DV9K902246
* Transportnumber : DV9K902246
*---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_HEADER_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->pr_F_AFKO text
* <--pr_LWA_Z1E1AFKOL001 text
*----------------------------------------------------------------------*
FORM get_header_data TABLES pr_idoc_data TYPE idoc_data "IDOC data
USING pr_f_afko TYPE e3afkol " Afko str
ucture
pr_c_z1e1afkol001 TYPE edilsegtyp "Segment n
ame
CHANGING pr_lwa_z1e1afkol001 TYPE z1e1afkol001."Segment
structure
*------------L O C A L T Y P E S I N I T I A L L Z A T I O N------------
-*
*-----------------------------------------------------------------------*
*-------L O C A L D A T A D E C L A R A T I O N----------------------*
*-----------------------------------------------------------------------*
*--------L O C A L C O N S T A N T D E C L A R A T I O N------------*
*-----------------------------------------------------------------------*
*------------------D A T A I N I T I A L L Z A T I O N-----------------*
REFRESH : lt_afpo,
lt_marc,
lt_vbak,
lt_vbap,
lt_vbep,
lt_vbpa,
lt_likp,
lt_vbfa,
lt_kna1,
lt_user_addr,
lt_knvv,
lt_mara,
lt_aufm.
CLEAR : ls_afpo,
ls_marc,
ls_vbak,
ls_vbap,
ls_vbep,
ls_vbpa,
ls_likp,
ls_vbfa,
ls_kna1,
ls_user_addr,
ls_knvv,
ls_mara,
ls_aufm,
pr_lwa_z1e1afkol001.
*-----------------------------------------------------------------------*
* check prod order is not blank
IF pr_f_afko-aufnr IS NOT INITIAL .
* Fetch data from prod order line item
SELECT aufnr
posnr
kdauf
kdpos
uebto
untto
psmng
wemng
FROM afpo INTO TABLE lt_afpo
WHERE aufnr EQ pr_f_afko-aufnr.
IF sy-subrc EQ 0.
SORT lt_afpo BY aufnr. "Sort data by order number
* Assign Sales order and Line item
READ TABLE lt_afpo INTO ls_afpo WITH KEY aufnr = pr_f_afko-aufnr.
IF sy-subrc EQ 0.
pr_f_afko-kdauf = ls_afpo-kdauf.
pr_f_afko-kdpos = ls_afpo-kdpos.
CLEAR : ls_afpo.
ENDIF.
ENDIF.
ENDIF.
* fetch sales order schedule line data
SELECT vbeln
posnr
etenr
edatu
bmeng
wadat
FROM vbep INTO TABLE lt_vbep
WHERE vbeln EQ pr_f_afko-kdauf
AND posnr EQ pr_f_afko-kdpos
AND bmeng GT 0.
IF sy-subrc EQ 0.
* Sort data
SORT lt_vbep BY vbeln posnr edatu.
ENDIF.
pr_lwa_z1e1afkol001-sales_quantity = ls_vbap-kwmeng.
ENDIF.
IF sy-subrc EQ 0.
pr_lwa_z1e1afkol001-confirmation_date = ls_vbep-edatu.
pr_lwa_z1e1afkol001-goods_issue_date = ls_vbep-wadat.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
* text
*----------------------------------------------------------------------*
* -->pr_F_AFKO text
* <--pr_LWA_Z1E1AFKOL001 text
*----------------------------------------------------------------------*
FORM get_characteric_values TABLES pr_idoc_data TYPE idoc_data
USING pr_f_afko TYPE e3afkol
pr_c_z1char_value001 TYPE edilsegtyp
CHANGING pr_lwa_z1char_value001 TYPE z1char_value001.
*-------L O C A L D A T A D E C L A R A T I O N----------------------*
*-----------------------------------------------------------------------*
*--------L O C A L C O N S T A N T D E C L A R A T I O N------------*
* Charcteristic Values
CONSTANTS : lc_bundle_size TYPE atnam VALUE 'Z_BUNDLE_SIZE',
lc_family TYPE atnam VALUE 'Z_FAMILY',
lc_certificate_standard TYPE atnam VALUE 'Z_CERTIFICATE_S
TANDARD',
lc_coating_mass TYPE atnam VALUE 'Z_COATING_MASS'
,
lc_coil_inner_diameter TYPE atnam VALUE 'Z_COIL_INNER_DI
AMETER',
lc_coil_outer_diameter_max TYPE atnam VALUE 'Z_COIL_MAX_OUTE
R_DIAMETER',
lc_coil_outer_diameter_min TYPE atnam VALUE 'Z_COIL_MIN_OUTE
R_DIAMETER',
lc_coil_weight_max TYPE atnam VALUE 'Z_COIL_WEIGHT_M
AX',
lc_coil_weight_min TYPE atnam VALUE 'Z_COIL_WEIGHT_M
IN',
lc_colour_coating_colour_back TYPE atnam VALUE 'Z_COLOUR_COATIN
G_COLOUR_BACK',
lc_colour_coating_colour_front TYPE atnam VALUE 'Z_COLOUR_COATIN
G_COLOUR_FRONT',
lc_colour_coating_type_back TYPE atnam VALUE 'Z_COLOUR_COATI
NG_TYPE_BACK',
lc_colour_coating_type_front TYPE atnam VALUE 'Z_COLOUR_COATIN
G_TYPE_FRONT',
lc_customer_identificat_code TYPE atnam VALUE 'Z_CUSTOMER_IDEN
TIFICAT_CODE',
lc_delivery_condition TYPE atnam VALUE 'Z_DELIVERY_COND
ITION',
lc_density TYPE atnam VALUE 'Z_DENSITY',
lc_material_family TYPE atnam VALUE 'Z_MATERIAL_FAMI
LY',
lc_flatness_tolerance TYPE atnam VALUE 'Z_FLATNESS_TOLE
RANCE',
lc_grade TYPE atnam VALUE 'Z_GRADE',
lc_height TYPE atnam VALUE 'Z_HEIGHT',
lc_inside_diameter TYPE atnam VALUE 'Z_INSIDE_DIAMET
ER',
lc_kg_each_ratio TYPE atnam VALUE 'Z_KG_EACH_RATIO
',
lc_kg_metre_ratio TYPE atnam VALUE 'Z_KG_METRE_RATI
O',
lc_length TYPE atnam VALUE 'Z_LENGTH',
lc_length_tol_minus TYPE atnam VALUE 'Z_LENGTH_TOL_MI
NUS',
lc_length_tol_plus TYPE atnam VALUE 'Z_LENGTH_TOL_PL
US',
lc_manufacturing_instruction TYPE atnam VALUE 'Z_MANUFACTURING
_INSTRUCTION',
lc_marking TYPE atnam VALUE 'Z_MARKING',
lc_packing TYPE atnam VALUE 'Z_PACKING',
lc_packweight_max TYPE atnam VALUE 'Z_PACKWEIGHT_MA
X',
lc_packweight_min TYPE atnam VALUE 'Z_PACKWEIGHT_MI
N',
lc_pieces_per_pack TYPE atnam VALUE 'Z_PIECES_PER_PA
CK',
lc_protection TYPE atnam VALUE 'Z_PROTECTION',
lc_protective_film TYPE atnam VALUE 'Z_PROTECTIVE_FI
LM',
lc_standard TYPE atnam VALUE 'Z_STANDARD',
lc_surface_finish TYPE atnam VALUE 'Z_SURFACE_FINIS
H',
lc_thickness TYPE atnam VALUE 'Z_THICKNESS',
lc_thickness_tol_low TYPE atnam VALUE 'Z_THICKNESS_TOL
_LOW',
lc_thickness_tol_upp TYPE atnam VALUE 'Z_THICKNESS_TOL
_UPP',
lc_type TYPE atnam VALUE 'Z_TYPE',
lc_width TYPE atnam VALUE 'Z_WIDTH',
lc_width_tolerance_low TYPE atnam VALUE 'Z_WIDTH_TOLERAN
CE_LOW',
lc_width_tolerance_up TYPE atnam VALUE 'Z_WIDTH_TOLERAN
CE_UPP',
lc_picking_instruction TYPE atnam VALUE 'Z_PICKING_INSTR
UCTION',
lc_heat_number TYPE atnam VALUE 'Z_HEAT_NUMBER',
lc_max_pack_height TYPE atnam VALUE 'Z_MAX_PACK_HEIG
HT'.
*-----------------------------------------------------------------------*
*------------------D A T A I N I T I A L L Z A T I O N-----------------*
REFRESH : lt_configuration,
lt_configuration_idoc.
REFRESH : lt_e1cucfg,
lt_e1cuins,
lt_e1cuval,
lt_e1cucom.
CLEAR : ls_e1cuval.
CLEAR : ls_configuration,
ls_configuration_idoc,
lt_configuration,
lt_configuration_idoc,
lv_instance,
pr_lwa_z1char_value001.
*-----------------------------------------------------------------------*
* check Sales order and line item is not blank
* IF pr_f_afko-kdauf IS NOT INITIAL AND pr_f_afko-kdpos IS NOT INITIAL.
** fetch configuration from SO
* SELECT SINGLE cuobj FROM vbap
* INTO lv_instance
* WHERE vbeln EQ pr_f_afko-kdauf
* AND posnr EQ pr_f_afko-kdpos.
* IF sy-subrc EQ 0.
*
* ENDIF.
* ELSE.
** fetch configuration from Material master
* SELECT SINGLE cuobj FROM marc
* INTO lv_instance
* WHERE matnr EQ pr_f_afko-matnr
* AND werks EQ pr_f_afko-werks.
* IF sy-subrc EQ 0.
*
* ENDIF.
* ENDIF.
IF pr_f_afko-aufnr IS NOT INITIAL.
* get Configuration data
CALL FUNCTION 'ZPP_GET_CHAR_PROD_ORD'
EXPORTING
i_aufnr = pr_f_afko-aufnr
IMPORTING
et_configuration = lt_configuration
et_configuration_idoc = lt_configuration_idoc
EXCEPTIONS
ex_instance_not_found = 1
ex_internal_error = 2
ex_no_class_allocation = 3
ex_instance_not_valid = 4
ex_no_input_found = 5
ex_enter_single_input = 6
ex_enter_material_or_prod_orde = 7
ex_plant_cant_be_blank_for_mat = 8
OTHERS = 9.
IF sy-subrc EQ 0.
LOOP AT lt_configuration INTO ls_configuration.
CASE ls_configuration-atnam.
WHEN lc_family.
PERFORM fill_segment TABLES pr_idoc_data
USING lc_family
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_bundle_size.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_bundle_size
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_certificate_standard.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_certificate_standard
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_coating_mass.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_coating_mass
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_coil_inner_diameter.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_coil_inner_diameter
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_coil_outer_diameter_max.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_coil_outer_diameter_max
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_coil_outer_diameter_min.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_coil_outer_diameter_min
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_coil_weight_max.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_coil_weight_max
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_coil_weight_min.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_coil_weight_min
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_colour_coating_colour_back.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_colour_coating_colour_back
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_colour_coating_colour_front.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_colour_coating_colour_front
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_colour_coating_type_back.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_colour_coating_type_back
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_colour_coating_type_front.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_colour_coating_type_front
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_customer_identificat_code.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_customer_identificat_code
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_delivery_condition.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_delivery_condition
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_density.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_density
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_material_family.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_material_family
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_flatness_tolerance.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_flatness_tolerance
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_grade.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_grade
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_height.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_height
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_inside_diameter.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_inside_diameter
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_kg_each_ratio.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_kg_each_ratio
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_kg_metre_ratio.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_kg_metre_ratio
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_length.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_length
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_length_tol_minus.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_length_tol_minus
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_length_tol_plus.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_length_tol_plus
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_manufacturing_instruction.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_manufacturing_instruction
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_marking.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_marking
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_packing.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_packing
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_packweight_max.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_packweight_max
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_packweight_min.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_packweight_min
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_pieces_per_pack.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_pieces_per_pack
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_protection.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_protection
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_protective_film.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_protective_film
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_standard.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_standard
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_surface_finish.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_surface_finish
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_thickness.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_thickness
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_thickness_tol_low.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_thickness_tol_low
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_thickness_tol_upp.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_thickness_tol_upp
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_type.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_type
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_width.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_width
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_width_tolerance_low.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_width_tolerance_low
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_width_tolerance_up.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_width_tolerance_up
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_picking_instruction.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_picking_instruction
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_heat_number.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_heat_number
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN lc_max_pack_height.
* create IDOC for Characteristic values
PERFORM fill_segment TABLES pr_idoc_data
USING lc_max_pack_height
ls_configuration-atwrt
pr_c_z1char_value001
CHANGING pr_lwa_z1char_value001.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ELSE.
* Do Nothing
ENDIF.
ENDIF.
ENDFORM.
*-------L O C A L D A T A D E C L A R A T I O N----------------------*
*------------------D A T A I N I T I A L L Z A T I O N-----------------*
CLEAR : lv_frdlb,
pr_lwa_z1e1afvol001.
*-----------------------------------------------------------------------*
====
*&---------------------------------------------------------------------*
*& Include ZXLOIU02
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Program Description: USER EXIT to Assign values to custom segment *
* for Production order SAP to QUINTIQ *
* *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: *
* TRANSPORT NUMBER(S): DV9K900575 *
*---------------------------------------------------------------------*
* Modification : {Removed Break Statement}
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 03-02-2016
* Reason : {RFC, SIR or Ticket}
* Searchkey :
* Transportnumber : DV9K901555
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : Open Qunatity having negative singn at the end
* which fails in Quintiq. changes made in code to put
* minus sign at the front
* Modified by : Bhaskar
* Date (dd-mm-yyyy): 21-03-2016
* Reason : NA
* Searchkey : DV9K902013
* Transportnumber : DV9K902013
*---------------------------------------------------------------------*
*----------------------------------------------------------------------*
*-------------------D A T A D E C L A R A T I O N-------------------*
DATA : gs_z1e1afkol001 TYPE z1e1afkol001, "Custom Header segment
gs_z1e1afvol001 TYPE z1e1afvol001, "Custom Opertation segment
gs_z1char_value001 TYPE z1char_value001. "characteristic segment
*-----------------------------------------------------------------------*
*-------------------C O N S T A N T D E C L A R A T I O N------------*
CONSTANTS : lc_e1afkol TYPE edilsegtyp VALUE 'E1AFKOL', "Head
er segment
lc_z1e1afkol001 TYPE edilsegtyp VALUE 'Z1E1AFKOL001', "Cust
om Header segment
lc_e1afvol TYPE edilsegtyp VALUE 'E1AFVOL', "Oper
ation Segment
lc_z1e1afvol001 TYPE edilsegtyp VALUE 'Z1E1AFVOL001', "Cust
om Opertation segment
lc_z1char_value001 TYPE edilsegtyp VALUE 'Z1CHAR_VALUE001'. "char
acteristic segment
*-----------------------------------------------------------------------*
*------------------D A T A I N I T I A L L Z A T I O N-----------------*
* Clear work area
CLEAR : gs_z1e1afkol001,
gs_z1e1afvol001,
gs_z1char_value001.
*-----------------------------------------------------------------------*
CASE : segment_name.
SET COUNTRY 'GB'.
WHEN : lc_e1afkol.
* Fill IDOC data for Custom Header segment
PERFORM get_header_data TABLES idoc_data "IDOC Structure
USING f_afko "AFKO structure
lc_z1e1afkol001 "Segment name
CHANGING gs_z1e1afkol001. "Custom segment Struct
ure
ENDCASE.
====
*&---------------------------------------------------------------------*
*& Include ZI_SD_NORD_ITEMTXT
*&---------------------------------------------------------------------*
************************************************************************
*& Description : This include is created to retrieve the text details *
*& for the customer from the custom table, *
*& when the sales order is created for that customer. *
*& RICEFW NO : E_O2C_002 *
*& Author : Rupak Bhattacharjee *
*& Modification : N/A *
*& Modified by : N/A *
*& Transport : DV9K900094 *
*& Date : 07.01.2016 *
************************************************************************
**Range Declaration
DATA: lr_tdid TYPE RANGE OF tdid,
ls_tdid LIKE LINE OF lr_tdid.
*Sold to party
lv_sold = tvcom-kunnr.
IF sy-subrc EQ 0.
CASE lv_atnam.
* Family
WHEN 'Z_FAMILY'.
lv_family = ls_values-atwrt.
WHEN 'Z_TYPE'.
* Type
lv_type = ls_values-atwrt.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDIF.
* Search the Custom Table based on whatever is available , searching from max
imum to minmum and based on the Search Algorithm specified in the where claus
e.
LOOP AT lt_xthead INTO ls_xthead.
SELECT SINGLE * FROM zsd_custtext
INTO ls_cust_text
WHERE customer = lv_sold AND
textid = ls_xthead-tdid AND
shipto = lv_ship AND
plant = lv_werks AND
family = lv_family AND
type = lv_type AND
spras = lv_langu.
IF sy-subrc NE 0.
SELECT SINGLE * FROM zsd_custtext
INTO ls_cust_text
WHERE customer = lv_sold AND
textid = ls_xthead-tdid AND
shipto = lv_ship AND
plant = lv_werks AND
family = lv_family AND
spras = lv_langu.
IF sy-subrc NE 0.
SELECT SINGLE * FROM zsd_custtext
INTO ls_cust_text
WHERE customer = lv_sold AND
textid = ls_xthead-tdid AND
shipto = lv_ship AND
plant = lv_werks AND
spras = lv_langu.
IF sy-subrc NE 0.
SELECT SINGLE * FROM zsd_custtext
INTO ls_cust_text
WHERE customer = lv_sold AND
textid = ls_xthead-tdid AND
shipto = lv_ship AND
spras = lv_langu.
IF sy-subrc NE 0.
IF sy-subrc NE 0.
SELECT SINGLE * FROM zsd_custtext
INTO ls_cust_text
WHERE customer = lv_sold AND
textid = ls_xthead-tdid AND
plant = lv_werks AND
family = lv_family AND
spras = lv_langu.
IF sy-subrc NE 0.
SELECT SINGLE * FROM zsd_custtext
INTO ls_cust_text
WHERE customer = lv_sold AND
textid = ls_xthead-tdid AND
plant = lv_werks AND
spras = lv_langu.
IF sy-subrc NE 0.
SELECT SINGLE * FROM zsd_custtext
INTO ls_cust_text
WHERE customer = lv_sold AND
textid = ls_xthead-tdid AND
spras = lv_langu.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
IF sy-subrc EQ 0.
CLEAR ls_head.
MOVE-CORRESPONDING ls_xthead TO ls_head.
ls_head-tdspras = ls_head_cust-tdspras.
ENDIF.
ENDIF."Read Text
ENDIF.
CLEAR ls_xthead.
ENDLOOP.
ENDIF.
ENDIF."Sy-tcode
=====
*&---------------------------------------------------------------------*
*& Include ZI_PP_PROD_ORDER_FORMS
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Program Description: Driver program for Production order smartform *
* DEVELOPER: Akanksha Jain *
* CREATION DATE: 05/01/2015 *
* OBJECT NUMBER: PP_004 *
* TRANSPORT NUMBER(S): DV9K900569,DV9K900618 *
* INPUT: Production order number *
* Output: Display form *
*----------------------------------------------------------------------*
* REVISION HISTORY-----------------------------------------------------*
* REVISION NO: 1. REFERENCE NO: D_111 *
* DEVELOPER : Surajit Dubey *
* TRANSPORT : DV9K902323 *
* DESCRIPTION: Implementing Defect 111(F_PP_004) *
* Supress print preview *
* DATE : 29.03.2016 *
* SEARCH KEY : N/A *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form F_read_memory_DATA
*&---------------------------------------------------------------------*
* Contains a FM which imports the Production order data from the
* standard transaction CO02, CO03.
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_read_memory_data .
DATA : ls_print_co TYPE print_co,
ls_print_opts TYPE itcpo,
ls_crhd TYPE gty_crhd,
ls_affl TYPE gty_affl,
ls_caufv TYPE gty_caufv,
ls_usr21 TYPE gty_usr21,
ls_adr2 TYPE gty_adr2,
ls_afko TYPE gty_afko,
ls_afvc TYPE gty_afvc,
ls_afpo TYPE gty_afpo,
ls_vbak TYPE gty_vbak,
ls_vbkd TYPE gty_vbkd,
ls_vbkd1 TYPE gty_vbkd,
ls_vbep TYPE gty_vbep,
ls_vbep1 TYPE gty_vbep,
lt_tline TYPE tline_t,
ls_tline TYPE tline,
ls_usrname TYPE gty_usrname,
ls_final TYPE zpp_s_prod_order_details,
lt_final TYPE STANDARD TABLE OF zpp_s_prod_order_details,
ls_comp_data TYPE zpp_s_prod_order_comp_details,
lt_comp_data TYPE STANDARD TABLE OF zpp_s_prod_order_comp_details,
ls_addr TYPE zpp_s_prod_order_addr_details,
ls_addr1 TYPE zpp_s_prod_order_addr_details,
lt_addr TYPE STANDARD TABLE OF zpp_s_prod_order_addr_details,
lt_resb TYPE gty_t_resb,
ls_vbap TYPE gty_vbap,
ls_conf_data TYPE zpp_s_po_conf_data,
lt_conf_data TYPE zpp_t_po_conf_data,
lt_vc_data TYPE zpp_t_po_conf_data,
ls_vc_data TYPE zpp_s_po_conf_data,
lt_mat_data TYPE gty_t_mat_data,
lt_vbpa TYPE gty_t_vbpa,
lt_adrc TYPE gty_t_adrc.
IF sy-subrc IS INITIAL.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_PRINT_INFO_LIST
*&---------------------------------------------------------------------*
* This form fetches data into the stucture which contains
* production order details
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_print_info_list CHANGING pr_ls_print_co TYPE print_co
pr_ls_print_opts TYPE itcpo.
* Exception handling not required as the function module is not returning any
thing.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_GET_ORDER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_get_order USING pr_ls_print_co TYPE print_co
CHANGING pr_ls_caufv TYPE gty_caufv.
CLEAR: pr_ls_caufv.
IF pr_ls_print_co-aufnr IS NOT INITIAL.
SELECT SINGLE aufnr gstrp gltrp
gsuzp gluzp plnbez gamng gmein werks
FROM caufv INTO pr_ls_caufv
WHERE aufnr = pr_ls_print_co-aufnr.
IF sy-subrc EQ 0.
* Above select can not fail as production order form is triggered from
* order and order number is promary key for the view cAUFV.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_get_data USING pr_ls_print_co TYPE print_co
pr_ls_caufv TYPE gty_caufv
CHANGING pr_ls_crhd TYPE gty_crhd
pr_ls_affl TYPE gty_affl
pr_ls_afko TYPE gty_afko
pr_ls_afvc TYPE gty_afvc
pr_ls_afpo TYPE gty_afpo
pr_ls_vbak TYPE gty_vbak
pr_ls_vbap TYPE gty_vbap
pr_ls_vbkd TYPE gty_vbkd
pr_ls_vbkd1 TYPE gty_vbkd
pr_ls_vbep TYPE gty_vbep
pr_ls_usr21 TYPE gty_usr21
pr_ls_adr2 TYPE gty_adr2
pr_lt_tline TYPE tline_t
pr_ls_tline TYPE tline
pr_ls_usrname TYPE gty_usrname
pr_ls_vbep1 TYPE gty_vbep
pr_lt_resb TYPE gty_t_resb
pr_lt_mat_data TYPE gty_t_mat_data
pr_lt_vbpa TYPE gty_t_vbpa
pr_lt_adrc TYPE gty_t_adrc.
IF sy-subrc EQ 0.
*&--fetch operation within a order
SELECT SINGLE aufpl arbid
FROM afvc INTO pr_ls_afvc
WHERE aufpl = pr_ls_afko-aufpl.
IF sy-subrc EQ 0.
SELECT SINGLE objid arbpl
FROM crhd INTO pr_ls_crhd
WHERE objid = pr_ls_afvc-arbid.
IF sy-subrc EQ 0.
SELECT SINGLE aufpl plnfl
FROM affl INTO pr_ls_affl
WHERE aufpl = pr_ls_afvc-aufpl.
IF sy-subrc = 0.
ENDIF.
IF sy-subrc = 0.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*&--fetch production order item details
SELECT SINGLE aufnr kdauf
kdpos kdein FROM afpo INTO pr_ls_afpo
WHERE aufnr = pr_ls_afko-aufnr.
IF sy-subrc EQ 0.
*&--fetch sales order header data
SELECT SINGLE vbeln ernam
FROM vbak INTO pr_ls_vbak
WHERE vbeln = pr_ls_afpo-kdauf.
IF sy-subrc EQ 0.
ENDIF.
*&--Fetching First Name & Last Name of User.
IF pr_ls_vbak-ernam IS NOT INITIAL.
PERFORM f_get_username USING pr_ls_vbak
CHANGING pr_ls_usrname.
ENDIF.
*&--fetch reservation material and quantity
SELECT matnr bdmng meins aufnr
FROM resb INTO TABLE pr_lt_resb
WHERE aufnr = pr_ls_afko-aufnr.
ls_resb-matnr = pr_ls_caufv-plnbez.
APPEND ls_resb TO pr_lt_resb.
IF pr_lt_resb IS NOT INITIAL.
SELECT matnr maktx INTO TABLE pr_lt_mat_data
FROM makt FOR ALL ENTRIES IN pr_lt_resb
WHERE matnr = pr_lt_resb-matnr.
ENDIF.
*&--fetch telephone number
SELECT SINGLE bname addrnumber FROM usr21
INTO pr_ls_usr21
WHERE bname = pr_ls_vbak-ernam.
IF sy-subrc EQ 0.
SELECT SINGLE addrnumber tel_number FROM adr2
INTO pr_ls_adr2
WHERE addrnumber = pr_ls_usr21-addrnumber.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_POPULATE_DATA
*&---------------------------------------------------------------------*
* This form contains all data which needs to be passed in the
* smartform ZPP_PROD_ORDER
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_populate_data USING pr_ls_caufv TYPE gty_caufv
pr_ls_afpo TYPE gty_afpo
pr_ls_vbap TYPE gty_vbap
pr_ls_usrname TYPE gty_usrname
pr_lt_mat_data TYPE gty_t_mat_data
pr_ls_crhd TYPE gty_crhd
pr_ls_vbep1 TYPE gty_vbep
pr_ls_vbkd1 TYPE gty_vbkd
pr_ls_adr2 TYPE gty_adr2
pr_ls_affl TYPE gty_affl
pr_lt_vbpa TYPE gty_t_vbpa
pr_lt_adrc TYPE gty_t_adrc
pr_lt_resb TYPE gty_t_resb
CHANGING pr_ls_final TYPE zpp_s_prod_order_details
pr_lt_final TYPE gty_final
pr_ls_comp_data TYPE zpp_s_prod_order_comp_details
pr_lt_comp_data TYPE gty_comp_data
pr_ls_addr TYPE zpp_s_prod_order_addr_details
pr_ls_addr1 TYPE zpp_s_prod_order_addr_details
pr_lt_addr TYPE gty_addr.
pr_ls_final-plnfl = pr_ls_affl-plnfl.
pr_ls_final-rueck = pr_ls_affl-rueck.
IF ls_vbpa-parvw = gc_ag.
pr_ls_addr-parvw = ls_vbpa-parvw.
pr_ls_addr-kunnr = ls_vbpa-kunnr.
READ TABLE pr_lt_adrc INTO ls_adrc WITH KEY
addrnumber = ls_vbpa-adrnr.
IF sy-subrc EQ 0.
pr_ls_addr-adrnr = ls_adrc-addrnumber.
pr_ls_addr-name1 = ls_adrc-name1.
pr_ls_addr-city1 = ls_adrc-city1.
pr_ls_addr-post_code1 = ls_adrc-post_code1.
ENDIF.
ENDIF.
IF ls_vbpa-parvw = gc_we.
pr_ls_addr1-parvw = ls_vbpa-parvw.
pr_ls_addr1-kunnr = ls_vbpa-kunnr.
READ TABLE pr_lt_adrc INTO gs_adrc WITH KEY
addrnumber = ls_vbpa-adrnr.
IF sy-subrc EQ 0.
pr_ls_addr1-adrnr = gs_adrc-addrnumber.
pr_ls_addr1-name1 = gs_adrc-name1.
pr_ls_addr1-city1 = gs_adrc-city1.
pr_ls_addr1-post_code1 = gs_adrc-post_code1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_CALL_FORM
*&---------------------------------------------------------------------*
* Passing the smartform name
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_call_form USING pr_ls_print_co TYPE print_co
pr_ls_print_opts TYPE itcpo
pr_ls_final TYPE zpp_s_prod_order_details
pr_ls_addr TYPE zpp_s_prod_order_addr_detail
s
pr_ls_addr1 TYPE zpp_s_prod_order_addr_detail
s
pr_ls_tline TYPE tline
pr_lt_comp_data TYPE gty_comp_data
pr_lt_conf_data TYPE zpp_t_po_conf_data.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_GET_USERNAME
*&---------------------------------------------------------------------*
* This Subroutine is used to get Username Details
*----------------------------------------------------------------------*
* -->PR_GS_VBAK text
* <--PR_GS_USRNAME text
*----------------------------------------------------------------------*
FORM f_get_username USING pr_gs_vbak TYPE gty_vbak
CHANGING pr_gs_usrname TYPE gty_usrname.
IF sy-subrc EQ 0.
*&--Description of characteristics
SELECT atinn atbez FROM cabnt
INTO TABLE lt_conf_desc
FOR ALL ENTRIES IN pr_lt_vc_data
WHERE atinn = pr_lt_vc_data-atinn.
IF sy-subrc EQ 0.
ENDIF.
*&--Characteristics - Z_TYPE
READ TABLE pr_lt_vc_data INTO pr_ls_vc_data
WITH KEY atnam = 'Z_TYPE' .
IF sy-subrc EQ 0 AND pr_ls_vc_data-atwrt IS NOT INITIAL.
pr_ls_conf_data-atnam = pr_ls_vc_data-atnam.
pr_ls_conf_data-atwrt = pr_ls_vc_data-atwrt.
READ TABLE lt_conf_desc INTO ls_conf_desc
WITH KEY atinn = pr_ls_vc_data-atinn.
IF sy-subrc EQ 0.
pr_ls_conf_data-atbez = ls_conf_desc-atbez.
ENDIF.
CLEAR pr_ls_vc_data.
APPEND pr_ls_conf_data TO pr_lt_conf_data.
ENDIF.
*&--Characteristics - Z_LENGTH
READ TABLE pr_lt_vc_data INTO pr_ls_vc_data
WITH KEY atnam = 'Z_LENGTH' .
IF sy-subrc EQ 0 AND pr_ls_vc_data-atwrt IS NOT INITIAL.
pr_ls_conf_data-atnam = pr_ls_vc_data-atnam.
pr_ls_conf_data-atwrt = pr_ls_vc_data-atwrt.
READ TABLE lt_conf_desc INTO ls_conf_desc
WITH KEY atinn = pr_ls_vc_data-atinn.
IF sy-subrc EQ 0.
pr_ls_conf_data-atbez = ls_conf_desc-atbez.
ENDIF.
CLEAR pr_ls_vc_data.
APPEND pr_ls_conf_data TO pr_lt_conf_data.
ENDIF.
*&--Characteristics - Z_LENGTH_TOL_PLUS
READ TABLE pr_lt_vc_data INTO pr_ls_vc_data
WITH KEY atnam = 'Z_LENGTH_TOL_PLUS' .
IF sy-subrc EQ 0 AND pr_ls_vc_data-atwrt IS NOT INITIAL.
pr_ls_conf_data-atnam = pr_ls_vc_data-atnam.
pr_ls_conf_data-atwrt = pr_ls_vc_data-atwrt.
READ TABLE lt_conf_desc INTO ls_conf_desc
WITH KEY atinn = pr_ls_vc_data-atinn.
IF sy-subrc EQ 0.
pr_ls_conf_data-atbez = ls_conf_desc-atbez.
ENDIF.
CLEAR pr_ls_vc_data.
APPEND pr_ls_conf_data TO pr_lt_conf_data.
ENDIF.
*&--Characteristics - Z_LENGTH_TOL_MINUS
READ TABLE pr_lt_vc_data INTO pr_ls_vc_data
WITH KEY atnam = 'Z_LENGTH_TOL_MINUS' .
IF sy-subrc EQ 0 AND pr_ls_vc_data-atwrt IS NOT INITIAL.
pr_ls_conf_data-atnam = pr_ls_vc_data-atnam.
pr_ls_conf_data-atwrt = pr_ls_vc_data-atwrt.
READ TABLE lt_conf_desc INTO ls_conf_desc
WITH KEY atinn = pr_ls_vc_data-atinn.
IF sy-subrc EQ 0.
pr_ls_conf_data-atbez = ls_conf_desc-atbez.
ENDIF.
CLEAR pr_ls_vc_data.
APPEND pr_ls_conf_data TO pr_lt_conf_data.
ENDIF.
*&--Characteristics - Z_THICKNESS
*&--Characteristics - Z_PACKWEIGHT_MAX
READ TABLE pr_lt_vc_data INTO pr_ls_vc_data
WITH KEY atnam = 'Z_PACKWEIGHT_MAX' .
IF sy-subrc EQ 0 AND pr_ls_vc_data-atwrt IS NOT INITIAL.
pr_ls_conf_data-atnam = pr_ls_vc_data-atnam.
pr_ls_conf_data-atwrt = pr_ls_vc_data-atwrt.
READ TABLE lt_conf_desc INTO ls_conf_desc
WITH KEY atinn = pr_ls_vc_data-atinn.
IF sy-subrc EQ 0.
pr_ls_conf_data-atbez = ls_conf_desc-atbez.
ENDIF.
CLEAR pr_ls_vc_data.
APPEND pr_ls_conf_data TO pr_lt_conf_data.
ENDIF.
*&--Characteristics - Z_WIDTH
READ TABLE pr_lt_vc_data INTO pr_ls_vc_data
WITH KEY atnam = 'Z_WIDTH' .
IF sy-subrc EQ 0 AND pr_ls_vc_data-atwrt IS NOT INITIAL.
pr_ls_conf_data-atnam = pr_ls_vc_data-atnam.
pr_ls_conf_data-atwrt = pr_ls_vc_data-atwrt.
READ TABLE lt_conf_desc INTO ls_conf_desc
WITH KEY atinn = pr_ls_vc_data-atinn.
IF sy-subrc EQ 0.
pr_ls_conf_data-atbez = ls_conf_desc-atbez.
ENDIF.
CLEAR pr_ls_vc_data.
APPEND pr_ls_conf_data TO pr_lt_conf_data.
ENDIF.
*&--Characteristics - Z_RM_PACKING_CODE
READ TABLE pr_lt_vc_data INTO pr_ls_vc_data
WITH KEY atnam = 'Z_RM_PACKING_CODE' .
IF sy-subrc EQ 0 AND pr_ls_vc_data-atwrt IS NOT INITIAL.
pr_ls_conf_data-atnam = pr_ls_vc_data-atnam.
pr_ls_conf_data-atwrt = pr_ls_vc_data-atwrt.
READ TABLE lt_conf_desc INTO ls_conf_desc
WITH KEY atinn = pr_ls_vc_data-atinn.
IF sy-subrc EQ 0.
pr_ls_conf_data-atbez = ls_conf_desc-atbez.
ENDIF.
CLEAR pr_ls_vc_data.
APPEND pr_ls_conf_data TO pr_lt_conf_data.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
======
*&---------------------------------------------------------------------*
* Program Description: Driver program for Production order smartform *
* DEVELOPER: Akanksha Jain *
* CREATION DATE: 05/01/2015 *
* OBJECT NUMBER: PP_004 *
* TRANSPORT NUMBER(S): DV9K900569,DV9K900618 *
* INPUT: Production order number *
* Output: Display form *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include ZI_PP_PROD_ORDER_TOP
*&---------------------------------------------------------------------*
*&--Structure
TYPES: BEGIN OF gty_caufv,
aufnr TYPE aufnr,
gstrp TYPE pm_ordgstrp,
gltrp TYPE co_gltrp,
gsuzp TYPE co_gsuzp,
gluzp TYPE co_gluzp,
plnbez TYPE matnr,
gamng TYPE gamng,
gmein TYPE co_gmein,
werks TYPE werks_d,
END OF gty_caufv,
BEGIN OF gty_afko,
aufnr TYPE aufnr,
aufpl TYPE co_aufpl,
END OF gty_afko,
BEGIN OF gty_afpo,
aufnr TYPE aufnr,
kdauf TYPE co_kdauf,
kdpos TYPE co_kdpos,
kdein TYPE kdein,
END OF gty_afpo,
BEGIN OF gty_vbak,
vbeln TYPE vbeln_va,
ernam TYPE ernam,
END OF gty_vbak,
BEGIN OF gty_usrname,
ernam TYPE ernam,
firstname TYPE ad_namefir,
lastname TYPE ad_namelas,
END OF gty_usrname,
BEGIN OF gty_vbap,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
kdmat TYPE matnr_ku,
route TYPE route,
lgort TYPE lgort_d,
kwmeng TYPE kwmeng,
vrkme TYPE vrkme,
END OF gty_vbap,
BEGIN OF gty_afvc,
aufpl TYPE co_aufpl,
arbid TYPE cr_objid,
END OF gty_afvc,
BEGIN OF gty_crhd,
objid TYPE cr_objid,
arbpl TYPE arbpl,
END OF gty_crhd,
BEGIN OF gty_affl,
aufpl TYPE co_aufpl,
plnfl TYPE plnfolge,
rueck TYPE co_rueck, "MD
END OF gty_affl,
BEGIN OF gty_vbep,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
edatu TYPE edatu,
wadat TYPE wadat,
END OF gty_vbep,
BEGIN OF gty_vbkd,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
bstkd TYPE bstkd,
END OF gty_vbkd,
BEGIN OF gty_vbpa,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
parvw TYPE parvw,
adrnr TYPE adrnr,
kunnr TYPE kunnr,
END OF gty_vbpa,
gty_t_vbpa TYPE STANDARD TABLE OF gty_vbpa,
BEGIN OF gty_adrc,
addrnumber TYPE ad_addrnum,
name1 TYPE ad_name1,
city1 TYPE ad_city1,
post_code1 TYPE ad_pstcd1,
END OF gty_adrc,
gty_t_adrc TYPE STANDARD TABLE OF gty_adrc,
BEGIN OF gty_usr21,
bname TYPE xubname,
addrnumber TYPE ad_addrnum,
END OF gty_usr21,
BEGIN OF gty_adr2,
addrnumber TYPE ad_addrnum,
tel_number TYPE ad_tlnmbr,
END OF gty_adr2,
BEGIN OF gty_makt,
matnr TYPE matnr,
maktx TYPE maktx,
END OF gty_makt,
BEGIN OF gty_resb,
matnr TYPE matnr,
bdmng TYPE bdmng,
meins TYPE meins,
aufnr TYPE aufnr,
END OF gty_resb,
gty_t_resb TYPE STANDARD TABLE OF gty_resb,
BEGIN OF gty_mat_data,
matnr TYPE matnr,
maktx TYPE maktx,
END OF gty_mat_data,
gty_t_mat_data TYPE STANDARD TABLE OF gty_mat_data.
====
*&---------------------------------------------------------------------*
*& Include ZI_PP_PROD_ORDR_SEND_QUINTIQ
*&---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : {To trigger IDOC for production order from Sales Order
* program RCCLORD is called. in Production Order
* there is no o/p type concept for IDOC trigger.
* We have tried Event but that is also not working as req
uirement is
* to trigger IDOC when Prod created or change }
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 10-03-2016
* Reason : NA
* Searchkey : DV9K901857
* Transportnumber : DV9K901857
*---------------------------------------------------------------------*
* REVISION HISTORY-----------------------------------------------------*
* REVISION NO: 1. REFERENCE NO: Ticket 594623 *
* DEVELOPER : Arunodaya Biswas *
* TRANSPORT : DV9K902949 *
* DESCRIPTION: Implement Wait for database commit *
* DATE : 20.04.2016 *
* SEARCH KEY : T_594623 *
*&---------------------------------------------------------------------*
*------------L O C A L T Y P E S I N I T I A L L Z A T I O N------------
-*
TYPES : BEGIN OF lty_aufnr,
sign TYPE c LENGTH 1,
option TYPE c LENGTH 2,
low TYPE aufnr,
high TYPE aufnr,
END OF lty_aufnr.
*-------L O C A L D A T A D E C L A R A T I O N----------------------*
DATA : lt_aufnr TYPE STANDARD TABLE OF lty_aufnr INITIAL SIZE 0,
lwa_aufnr TYPE lty_aufnr,
lt_werks TYPE STANDARD TABLE OF lty_werks INITIAL SIZE 0,
lwa_werks TYPE lty_werks,
lt_matnr TYPE STANDARD TABLE OF lty_matnr,
lwa_matnr TYPE lty_matnr,
lv_logsys TYPE logsys.
*-------------------C O N S T A N T D E C L A R A T I O N------------*
CONSTANTS : lc_sign(1) TYPE c VALUE 'I',
lc_option(2) TYPE c VALUE 'EQ',
lc_dev TYPE logsys VALUE 'SAPPID',
lc_test TYPE logsys VALUE 'SAPPIQ',
lc_prod TYPE logsys VALUE 'SAPPIP',
lc_mestyp TYPE edi_mestyp VALUE 'ZLOIPRO_100216',
lc_auart TYPE auart VALUE 'ZPN1',
lc_dv9 TYPE sysid VALUE 'DV9',
lc_ts9 TYPE sysid VALUE 'TS9',
lc_pr9 TYPE sysid VALUE 'PR9',
lc_zpc1 TYPE auart VALUE 'ZPC1'.
*------------------D A T A I N I T I A L L Z A T I O N-----------------*
REFRESH : lt_aufnr,
lt_werks.
CLEAR : lwa_aufnr,
lwa_werks,
lv_logsys.
CLEAR : gs_caufvd.
*-------------------------------------------------------------------------*
WAIT UP TO 5 SECONDS."++T_594623
IMPORT gs_caufvd FROM MEMORY ID 'PRODORD'.
*-------------------------------------------------------------------------*
IF gs_caufvd-auart EQ lc_auart.
IF sy-sysid EQ lc_dv9.
lv_logsys = lc_dev.
ELSEIF sy-sysid EQ lc_ts9.
lv_logsys = lc_test.
ELSEIF sy-sysid EQ lc_pr9.
lv_logsys = lc_prod.
ELSE.
lv_logsys = space.
ENDIF.
CLEAR : lwa_aufnr,
lwa_werks,
lv_logsys.
CLEAR : gs_caufvd.
ENDIF.
=====
*&---------------------------------------------------------------------*
* Program Description: Top include for production order smartform *
* DEVELOPER: C059014 *
* CREATION DATE: 24/12/2015 *
* OBJECT NUMBER: F_PP_004 *
* TRANSPORT NUMBER(S): DV9K900493 *
* INPUT: NA *
* Output: display form output *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include ZI_PP_PROD_ORDR_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form F_PROCESSING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PR_GV_US_SCREEN text
* <--P_PR_GV_RETURN_CODE text
*----------------------------------------------------------------------*
FORM f_processing .
* USING p_pr_gv_us_screen type c
* CHANGING p_pr_gv_return_code type i.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_CALL_SMARTFORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_call_smartform .
* Local variable declaration
DATA: lv_fm_name TYPE rs38l_fnam.
ENDFORM.
==================================================================
FUNCTION zpp_get_char_prod_ord.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_AUFNR) TYPE AUFNR OPTIONAL
*" REFERENCE(I_MATNR) TYPE MATNR OPTIONAL
*" REFERENCE(I_PLANT) TYPE WERKS_D OPTIONAL
*" EXPORTING
*" REFERENCE(ET_CONFIGURATION) TYPE TT_CONF_OUT
*" REFERENCE(ET_CONFIGURATION_IDOC) TYPE TT_API_VALUE
*" EXCEPTIONS
*" EX_INSTANCE_NOT_FOUND
*" EX_INTERNAL_ERROR
*" EX_NO_CLASS_ALLOCATION
*" EX_INSTANCE_NOT_VALID
*" EX_NO_INPUT_FOUND
*" EX_ENTER_SINGLE_INPUT
*" EX_ENTER_MATERIAL_OR_PROD_ORDE
*" EX_PLANT_CANT_BE_BLANK_FOR_MAT
*" EX_INVALID_INPUT
*" EX_INSTANCE_IS_A_CLASSIFICATIO
*"----------------------------------------------------------------------
*&---------------------------------------------------------------------*
* Program Description: Function module to Get Characteristic Value
* for Production order *
* *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: *
* TRANSPORT NUMBER(S): DV9K900647 *
* INPUT: Production Order input data *
* Output: get Characteristics Value *
*----------------------------------------------------------------------*
* Input Either material or Production Order
IF i_matnr IS INITIAL AND i_aufnr IS INITIAL .
* raise Exception
RAISE ex_no_input_found.
ENDIF.
ENDFUNCTION.
*----------------------------------------------------------------------*
***INCLUDE LZPP_GET_CHARF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IM_AUFNR text
* <--P_G_CUOBJ text
*----------------------------------------------------------------------*
FORM get_data USING pr_im_aufnr TYPE aufnr
CHANGING pr_g_cuobj TYPE cuobj.
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : lv_matnr TYPE matnr,
lv_vbeln TYPE vbeln,
lv_posnr TYPE posnr,
lv_werks TYPE werks_d,
lt_pstyv TYPE RANGE OF vbap-pstyv.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lr_pstyv.
CLEAR : lv_matnr,
lv_vbeln,
lv_posnr,
lv_werks,
lt_pstyv.
*----------------------------------------------------------------------*
* Check SO Item Category
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zapr.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zbp0.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_znre.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zpre.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
* Check Production order is not blank
IF pr_im_aufnr IS NOT INITIAL.
* fetch production order header data
SELECT SINGLE plnbez
werks
kdauf
kdpos FROM caufv
INTO (lv_matnr, lv_werks, lv_vbeln, lv_posnr)
WHERE aufnr EQ pr_im_aufnr.
IF sy-subrc EQ 0.
* check SO and SO item is not blank
IF lv_vbeln IS NOT INITIAL AND lv_posnr IS NOT INITIAL.
* fetch CUOBJ from Sales order
SELECT SINGLE cuobj
FROM vbap
INTO pr_g_cuobj
WHERE vbeln EQ lv_vbeln
AND posnr EQ lv_posnr
AND pstyv NOT IN lt_pstyv.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* fetch CUOBJ from material master
SELECT SINGLE cuobj
FROM marc
INTO pr_g_cuobj
WHERE matnr EQ lv_matnr
AND werks EQ lv_werks.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
* CUOBJ Found
ENDIF.
ELSE.
* fetch CUOBJ from material master
SELECT SINGLE cuobj
FROM marc
INTO pr_g_cuobj
WHERE matnr EQ lv_matnr
AND werks EQ lv_werks.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
ENDIF.
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_CHAR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PR_G_CUOBJ text
*----------------------------------------------------------------------*
FORM get_char_data USING pr_g_cuobj
CHANGING ch_t_configuration TYPE tt_conf_out
ch_t_configuration_idoc TYPE tt_api_value .
REFRESH : lt_conf.
CLEAR : ls_conf,
ls_conft,
ls_conf,
lv_value,
ls_conf_out.
*----------------------------------------------------------------------*
***INCLUDE LZPP_GET_CHARF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IM_AUFNR text
* <--P_G_CUOBJ text
*----------------------------------------------------------------------*
FORM get_data USING pr_im_aufnr TYPE aufnr
CHANGING pr_g_cuobj TYPE cuobj.
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : lv_matnr TYPE matnr,
lv_vbeln TYPE vbeln,
lv_posnr TYPE posnr,
lv_werks TYPE werks_d,
lt_pstyv TYPE RANGE OF vbap-pstyv.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lr_pstyv.
CLEAR : lv_matnr,
lv_vbeln,
lv_posnr,
lv_werks,
lt_pstyv.
*----------------------------------------------------------------------*
* Check SO Item Category
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zapr.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zbp0.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_znre.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zpre.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
* Check Production order is not blank
IF pr_im_aufnr IS NOT INITIAL.
* fetch production order header data
SELECT SINGLE plnbez
werks
kdauf
kdpos FROM caufv
INTO (lv_matnr, lv_werks, lv_vbeln, lv_posnr)
WHERE aufnr EQ pr_im_aufnr.
IF sy-subrc EQ 0.
* check SO and SO item is not blank
IF lv_vbeln IS NOT INITIAL AND lv_posnr IS NOT INITIAL.
* fetch CUOBJ from Sales order
SELECT SINGLE cuobj
FROM vbap
INTO pr_g_cuobj
WHERE vbeln EQ lv_vbeln
AND posnr EQ lv_posnr
AND pstyv NOT IN lt_pstyv.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* fetch CUOBJ from material master
SELECT SINGLE cuobj
FROM marc
INTO pr_g_cuobj
WHERE matnr EQ lv_matnr
AND werks EQ lv_werks.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
* CUOBJ Found
ENDIF.
ELSE.
* fetch CUOBJ from material master
SELECT SINGLE cuobj
FROM marc
INTO pr_g_cuobj
WHERE matnr EQ lv_matnr
AND werks EQ lv_werks.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
ENDIF.
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_CHAR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PR_G_CUOBJ text
*----------------------------------------------------------------------*
FORM get_char_data USING pr_g_cuobj
CHANGING ch_t_configuration TYPE tt_conf_out
ch_t_configuration_idoc TYPE tt_api_value .
REFRESH : lt_conf.
CLEAR : ls_conf,
ls_conft,
ls_conf,
lv_value,
ls_conf_out.
*----------------------------------------------------------------------*
***INCLUDE LZPP_GET_CHARF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IM_AUFNR text
* <--P_G_CUOBJ text
*----------------------------------------------------------------------*
FORM get_data USING pr_im_aufnr TYPE aufnr
CHANGING pr_g_cuobj TYPE cuobj.
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : lv_matnr TYPE matnr,
lv_vbeln TYPE vbeln,
lv_posnr TYPE posnr,
lv_werks TYPE werks_d,
lt_pstyv TYPE RANGE OF vbap-pstyv.
RANGES : lr_pstyv FOR vbap-pstyv.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lr_pstyv.
CLEAR : lv_matnr,
lv_vbeln,
lv_posnr,
lv_werks,
lt_pstyv.
*----------------------------------------------------------------------*
* Check SO Item Category
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zapr.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zbp0.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_znre.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
lr_pstyv-sign = c_sign.
lr_pstyv-option = c_option.
lr_pstyv-low = lc_zpre.
APPEND lr_pstyv TO lt_pstyv.
CLEAR : lr_pstyv.
* Check Production order is not blank
IF pr_im_aufnr IS NOT INITIAL.
* fetch production order header data
SELECT SINGLE plnbez
werks
kdauf
kdpos FROM caufv
INTO (lv_matnr, lv_werks, lv_vbeln, lv_posnr)
WHERE aufnr EQ pr_im_aufnr.
IF sy-subrc EQ 0.
* check SO and SO item is not blank
IF lv_vbeln IS NOT INITIAL AND lv_posnr IS NOT INITIAL.
* fetch CUOBJ from Sales order
SELECT SINGLE cuobj
FROM vbap
INTO pr_g_cuobj
WHERE vbeln EQ lv_vbeln
AND posnr EQ lv_posnr
AND pstyv NOT IN lt_pstyv.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* fetch CUOBJ from material master
SELECT SINGLE cuobj
FROM marc
INTO pr_g_cuobj
WHERE matnr EQ lv_matnr
AND werks EQ lv_werks.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
* CUOBJ Found
ENDIF.
ELSE.
* fetch CUOBJ from material master
SELECT SINGLE cuobj
FROM marc
INTO pr_g_cuobj
WHERE matnr EQ lv_matnr
AND werks EQ lv_werks.
IF sy-subrc EQ 0.
* CUOBJ Found
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
ENDIF.
ELSE.
* Raise exception
RAISE ex_instance_not_found.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_CHAR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PR_G_CUOBJ text
*----------------------------------------------------------------------*
FORM get_char_data USING pr_g_cuobj
CHANGING ch_t_configuration TYPE tt_conf_out
ch_t_configuration_idoc TYPE tt_api_value .
REFRESH : lt_conf.
CLEAR : ls_conf,
ls_conft,
ls_conf,
lv_value,
ls_conf_out.
==================================================
FUNCTION zpp_prodord_update_table.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IS_HEADER) TYPE Z100217_INBOUNDSI_IA_WORK_INST
*" REFERENCE(IT_OPERATION) TYPE Z100217_INBOUNDMATERIAL_TAB
*" OPTIONAL
*" REFERENCE(IT_ORDER) TYPE Z100217_INBOUNDSI_IA_WORK__TAB
*" OPTIONAL
*"----------------------------------------------------------------------
*&---------------------------------------------------------------------*
* Program Description: Function module to update Prod Order Custom *
* Table *
* DEVELOPER: Bhaskar Patil *
*
* CREATION DATE: 14/01/2016 *
* OBJECT NUMBER: I_PP_002 *
* TRANSPORT NUMBER(S): DV9K900647 *
*----------------------------------------------------------------------*
*-----------L O C A L T Y P E S D E C L A R A T I O N-----------------*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : ls_zpp_wi_header TYPE zpp_wi_header,
ls_operation TYPE z100217_inboundmaterial,
lv_times TYPE i,
lv_index TYPE i,
ls_afko TYPE lty_afko,
ls_afvc TYPE lty_afvc.
*----------------------------------------------------------------------*
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------*
CONSTANTS : lc_times TYPE i VALUE '10'.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
CLEAR :ls_zpp_wi_header,
ls_operation,
lv_index,
ls_afko,
ls_afvc.
*----------------------------------------------------------------------*
IF pr_is_header IS NOT INITIAL .
* Update Header Table
ls_zpp_wi_header-aufnr = pr_is_header-work_instruction_number.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_zpp_wi_header-aufnr
IMPORTING
output = ls_zpp_wi_header-aufnr.
ls_zpp_wi_header-gstrp = pr_is_header-basic_start_date.
ls_zpp_wi_header-gltrp = pr_is_header-basic_start_time.
*ls_zpp_wi_header-GSUZP = pr_is_header-
*ls_zpp_wi_header-GLUZP = pr_is_header-
ls_zpp_wi_header-sstrp = pr_is_header-basic_start_date.
ls_zpp_wi_header-ssuzp = pr_is_header-basic_start_time.
ls_zpp_wi_header-bdmng = pr_is_header-order_item_quantity.
ls_zpp_wi_header-meins = pr_is_header-base_unit_of_measure.
ls_zpp_wi_header-auart = pr_is_header-order_type.
ls_zpp_wi_header-werks = pr_is_header-plant.
ls_zpp_wi_header-arbid = pr_is_header-object_id.
*ls_zpp_wi_header-VORNR = pr_is_header-
ls_zpp_wi_header-setup_time = pr_is_header-setup_time.
*ls_zpp_wi_header-SETUP_UNIT = pr_is_header-
ls_zpp_wi_header-proc_time = pr_is_header-proc_time.
*ls_zpp_wi_header-PROC_UNIT = pr_is_header-
*ls_zpp_wi_header-ZTIMESTAMP = pr_is_header-
* Lock Table
IF ls_zpp_wi_header IS NOT INITIAL.
lv_times = 10.
DO .
lv_index = sy-index.
CALL FUNCTION 'ENQUEUE_EZPP_WI_HEADER'
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc EQ 0.
* Update Table
MODIFY zpp_wi_header FROM ls_zpp_wi_header .
IF sy-subrc EQ 0.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
* UnLock Table
CALL FUNCTION 'DEQUEUE_EZPP_WI_HEADER'.
EXIT.
ELSE.
IF lv_index EQ lc_times.
EXIT.
ENDIF.
* Implement suitable error handling here
ENDIF.
ENDDO.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form UPDATE_ITEM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IS_HEADER text
* -->P_IT_OPERATION[] text
*----------------------------------------------------------------------*
FORM update_item USING pr_is_header TYPE z100217_inboundsi_ia_work_inst
pr_it_operation TYPE z100217_inboundmaterial_tab.
*-----------L O C A L T Y P E S D E C L A R A T I O N---------------*
TYPES : BEGIN OF lty_cabn,
atinn TYPE atinn,
atnam TYPE atnam,
atfor TYPE atfor,
END OF lty_cabn.
*----------------------------------------------------------------------*
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : ls_zpp_wi_header TYPE zpp_wi_header,
ls_operation TYPE z100217_inboundmaterial,
ls_zpp_wi_item TYPE zpp_wi_item,
lt_zpp_wi_item TYPE STANDARD TABLE OF zpp_wi_item INITIAL SIZE 0,
lv_index TYPE i,
lt_zpp_item_char TYPE STANDARD TABLE OF zpp_item_char INITIAL SIZE 0,
ls_zpp_item_char TYPE zpp_item_char,
ls_char TYPE z100217_inboundsi_ia_work_ins5,
lt_cabn TYPE STANDARD TABLE OF lty_cabn INITIAL SIZE 0,
ls_cabn TYPE lty_cabn.
*----------------------------------------------------------------------*
*-----------L O C A L C O N S T A N T D E C L A R A T I O N----------*
CONSTANTS : lc_times TYPE i VALUE '10',
lc_char(4) TYPE c VALUE 'CHAR'.
*-----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH :lt_zpp_wi_item,
lt_zpp_item_char,
lt_cabn.
CLEAR :ls_zpp_wi_header,
ls_operation,
ls_zpp_wi_item,
lv_index,
ls_zpp_item_char,
ls_char,
ls_cabn.
*----------------------------------------------------------------------*
IF pr_it_operation IS NOT INITIAL.
* Fetch Characteristic Name
SELECT atinn
atnam
atfor
FROM cabn INTO TABLE lt_cabn.
IF sy-subrc EQ 0.
SORT lt_cabn BY atnam.
ENDIF.
ls_zpp_wi_item-units = ls_operation-pieces_end_product.
APPEND ls_zpp_wi_item TO lt_zpp_wi_item.
CLEAR : ls_zpp_wi_item.
LOOP AT ls_operation-material_characteristics-sequence-
material_characteristic INTO ls_char.
ls_zpp_item_char-aufnr = pr_is_header-work_instruction_number.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_zpp_item_char-aufnr
IMPORTING
output = ls_zpp_item_char-aufnr.
ls_zpp_item_char-posnr = ls_operation-position.
ls_zpp_item_char-atnam = ls_char-char_name.
READ TABLE lt_cabn INTO ls_cabn WITH KEY atnam = ls_char-char_name
BINARY SEARCH.
IF sy-subrc EQ 0.
IF ls_cabn-atfor = lc_char.
ls_zpp_item_char-atwrt = ls_char-char_value.
ELSE.
ls_zpp_item_char-atflv = ls_char-char_value.
ENDIF.
ENDIF.
APPEND ls_zpp_item_char TO lt_zpp_item_char.
CLEAR : ls_zpp_item_char.
ENDLOOP.
ENDLOOP.
ENDIF.
CLEAR : lv_index.
CLEAR : lv_index.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form UPDATE_ORDER_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ZPP_WI_PROD[] text
*----------------------------------------------------------------------*
FORM update_order_table USING pr_is_header TYPE z100217_inboundsi_ia_work_ins
t
pr_zpp_wi_prod TYPE z100217_inboundsi_ia_work__
tab.
*-----------L O C A L D A T A D E C L A R A T I O N-----------------*
DATA : ls_wi_prod TYPE z100217_inboundsi_ia_work_ins2,
lt_zpp_rel_wi_op TYPE STANDARD TABLE OF zpp_rel_wi_op INITIAL SIZE 0,
ls_zpp_rel_wi_op TYPE zpp_rel_wi_op,
lt_zpp_wi_prod TYPE STANDARD TABLE OF zpp_wi_prod INITIAL SIZE 0,
ls_zpp_wi_prod TYPE zpp_wi_prod,
lv_index TYPE i.
*----------------------------------------------------------------------*
*-----------L O C A L C O N S T A N T D E C L A R A T I O N---------*
CONSTANTS : lc_times TYPE i VALUE '10'.
*----------------------------------------------------------------------*
*-----------D A T A I N I T I A L I Z A T I O N-----------------------*
REFRESH : lt_zpp_rel_wi_op,
lt_zpp_wi_prod.
CLEAR : ls_wi_prod,
ls_zpp_rel_wi_op,
ls_zpp_wi_prod,
lv_index.
*----------------------------------------------------------------------*
ls_zpp_rel_wi_op-paufnr = ls_wi_prod-order_number.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_zpp_rel_wi_op-paufnr
IMPORTING
output = ls_zpp_rel_wi_op-paufnr.
ls_zpp_rel_wi_op-wi_post = pr_is_header-prev_order_number.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_zpp_rel_wi_op-wi_post
IMPORTING
output = ls_zpp_rel_wi_op-wi_post.
* ls_zpp_rel_wi_op-plnfl = ls_wi_prod-sequence_in_pattern.
IF pr_is_header-prev_order_number IS NOT INITIAL.
ls_zpp_rel_wi_op-final = abap_false.
ELSE.
ls_zpp_rel_wi_op-final = abap_true.
ENDIF.
APPEND ls_zpp_rel_wi_op TO lt_zpp_rel_wi_op.
CLEAR : ls_zpp_rel_wi_op.
ls_zpp_wi_prod-aufnr = ls_wi_prod-work_instruction_number.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_zpp_wi_prod-aufnr
IMPORTING
output = ls_zpp_wi_prod-aufnr.
ls_zpp_wi_prod-posnr = ls_wi_prod-sequence_in_pattern.
ls_zpp_wi_prod-paufnr = ls_wi_prod-order_number.
* Conversion Exit
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_zpp_wi_prod-paufnr
IMPORTING
output = ls_zpp_wi_prod-paufnr.
ls_zpp_wi_prod-vornr = ls_wi_prod-operation_number.
ls_zpp_wi_prod-werks = ls_wi_prod-plant.
ls_zpp_wi_prod-bdmng = ls_wi_prod-order_item_quantity.
ls_zpp_wi_prod-meins = ls_wi_prod-quantity_uom.
CALL FUNCTION 'UNIT_OF_MEASURE_ISO_TO_SAP'
EXPORTING
iso_code = ls_zpp_wi_prod-meins
IMPORTING
sap_code = ls_zpp_wi_prod-meins
* UNIQUE =
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ls_zpp_wi_prod-units = ls_wi_prod-pieces_end_product .
APPEND ls_zpp_wi_prod TO lt_zpp_wi_prod.
CLEAR : ls_zpp_wi_prod.
ENDLOOP.
ENDIF.
ENDIF.
CLEAR : lv_index.
=====================================================
FUNCTION zpp_vc_uom_conv_factors.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(GLOBALS) LIKE CUOV_00 STRUCTURE CUOV_00
*" TABLES
*" QUERY STRUCTURE CUOV_01
*" MATCH STRUCTURE CUOV_01
*" EXCEPTIONS
*" FAIL
*" INTERNAL_ERROR
*"----------------------------------------------------------------------
*---------------------------------------------------------------------*
* Function : VC UOM conversion factors
* Development name : E_O2C_010
* Author : Bhaskar patil
* Date (dd-mm-yyyy): 11-03-2016
* Transportnumber : DV9K901905
* Specification : VC UOM conversion factors.
* :
*---------------------------------------------------------------------*
* Modification : Meter ratio Logic Changed
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 16-03-2016
* Reason : NA
* Searchkey : DV9K902039
* Transportnumber : DV9K902039
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
REFRESH : match,
lt_zpp_vc_uomconv.
CLEAR : lv_meter_ratio,
lv_length,
lv_density,
lv_width,
lv_thickness,
lv_value,
ls_zpp_vc_uomconv.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*..get value of input characteristic Density
CALL FUNCTION 'CUOV_GET_FUNCTION_ARGUMENT'
EXPORTING
argument = lc_density
IMPORTING
num_val = lv_density
TABLES
query = query
EXCEPTIONS
arg_not_found = 01.
IF sy-subrc <> 0.
ENDIF.
CASE lv_z_r_gewei.
WHEN lc_ea.
ENDIF.
ENDIF.
WHEN lc_m2.
IF lv_density IS NOT INITIAL OR
lv_thickness IS NOT INITIAL .
WHEN OTHERS.
ENDCASE.
*..add result to the table of output characteristics
CALL FUNCTION 'CUOV_SET_FUNCTION_ARGUMENT'
EXPORTING
argument = lc_kg_metre_ratio
vtype = 'NUM'
num_val = lv_meter_ratio
TABLES
match = match
EXCEPTIONS
existing_value_replaced = 01.
ENDFUNCTION.
=========================================================================
CO_ZV_ORDER_POST
3823
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""$"$\SE:(1) Enhancement Exit EHP603_CO_ZV_ORDER_POST, Enhancem
ent PS_ST_EHP3_SFWS_SC_CO_ZV_POST, End
A
*$*$-Start: (1)--------------------------------------------------------------
-------------------$*$*
ENHANCEMENT 1 ZPP_ENH_CO_ZV_ORDER_POST. "active version
*---------------------------------------------------------------------*
* Modification : {To trigger IDOC we have to pass logical system to RCCLO
RD
* In Test Client Logical sys name is SAPPIQ, change made
* to assign correct Logical system.
* To trigger IDOC program RCCLORD is called. in Productio
n Order
* there is no o/p type concept for IDOC trigger.
* We have tried Event but that is also not working as req
uirement is
* to trigger IDOC when Prod created or change}
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 03-02-2016
* Reason : {RFC, SIR or Ticket}
* Searchkey :
* Transportnumber : DV9K901555
*---------------------------------------------------------------------*
*------------L O C A L T Y P E S I N I T I A L L Z A T I O N------------
-*
TYPES : BEGIN OF lty_aufnr,
sign TYPE c LENGTH 1,
option TYPE c LENGTH 2,
low TYPE aufnr,
high TYPE aufnr,
END OF lty_aufnr.
*-------------------C O N S T A N T D E C L A R A T I O N------------*
CONSTANTS : lc_sign(1) type c VALUE 'I',
lc_option(2) TYPE c VALUE 'EQ',
lc_dev TYPE LOGSYS VALUE 'SAPPID',
lc_test TYPE LOGSYS VALUE 'SAPPIQ',
lc_prod TYPE LOGSYS VALUE 'SAPPIP',
lc_mestyp TYPE edi_mestyp VALUE 'ZLOIPRO_100216',
lc_auart TYPE auart VALUE 'ZPN1',
lc_dv9 TYPE SYSID VALUE 'DV9',
lc_ts9 TYPE SYSID VALUE 'TS9',
lc_pr9 TYPE sysid VALUE 'PR9',
lc_zpc1 TYPE auart VALUE 'ZPC1'.
*-------L O C A L D A T A D E C L A R A T I O N----------------------*
DATA : lt_aufnr TYPE STANDARD TABLE OF lty_aufnr INITIAL SIZE 0,
lwa_aufnr TYPE lty_aufnr,
lt_werks TYPE STANDARD TABLE OF lty_werks INITIAL SIZE 0,
lwa_werks TYPE lty_werks,
lwa_header TYPE caufvdb,
lt_matnr TYPE STANDARD TABLE OF lty_matnr,
lwa_matnr TYPE lty_matnr,
lv_LOGSYS TYPE LOGSYS .
*------------------D A T A I N I T I A L L Z A T I O N-----------------*
REFRESH : lt_aufnr,
lt_werks.
CLEAR : lwa_aufnr,
lwa_werks,
lwa_header,
lv_LOGSYS.
* -------------------------------------------------------------------------*
IF caufvd-auart eq lc_auart.
IF sy-sysid eq lc_dv9.
lv_LOGSYS = lc_dev.
ELSEIF sy-sysid eq lc_ts9.
lv_LOGSYS = lc_test.
ELSEIF sy-sysid eq lc_pr9.
lv_LOGSYS = lc_prod.
else.
lv_LOGSYS = space.
ENDIF.
ENDIF.
ENDENHANCEMENT.
*$*$-End: (1)--------------------------------------------------------------
-------------------$*$*
ENDENHANCEMENT.
*$*$-End: EHP603_CO_ZV_ORDER_POST------------------------------------------
-------------------$*$*
ENDFUNCTION.
***INCLUDE MV45AFZA .
************************************************************************
* *
* This include is reserved for user modifications *
* *
* Forms for sales document processing *
* *
* The name of modification modules should begin with 'ZZ'. *
* *
************************************************************************
*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMKD *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product substitution. *
* *
* This form is called from form KOMKD_KOMPD_FUELLEN. *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_KOMKD.
* KOMKD-zzfield = xxxx-zzfield2.
ENDFORM.
*eject
*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMPD *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product substitution. *
* *
* This form is called from form KOMKD_KOMPD_FUELLEN. *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_KOMPD.
* KOMPD-zzfield = xxxx-zzfield2.
ENDFORM.
*eject
*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMKG *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product listing or exclusion. *
* *
* This form is called from form KOMKG_KOMPG_FUELLEN. *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_KOMKG.
* KOMKG-zzfield = xxxx-zzfield2.
ENDFORM.
*eject
*---------------------------------------------------------------------*
* FORM USEREXIT_MOVE_FIELD_TO_KOMPG *
*---------------------------------------------------------------------*
* This userexit can be used to move some fields into the *
* communication workarea for product listing or exclusion. *
* *
* This form is called from form KOMKG_KOMPG_FUELLEN. *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_MOVE_FIELD_TO_KOMPG.
* KOMPG-zzfield = xxxx-zzfield2.
ENDFORM.
*eject
*---------------------------------------------------------------------*
* FORM USEREXIT_REFRESH_DOCUMENT *
*---------------------------------------------------------------------*
* It is always necessary to refresh user-specific data before *
* the next document will be processed. *
* This can be done in this userexit. *
* This userexit can be used to refresh user-specific data *
* when the processing of a sales document is finished *
* - after the document is saved *
* - when you leave the document processing with F3 or F15 *
* It may be necessary to refresh user-specific data before *
* the next document will be processed. *
* *
* This form is called in dialog at the end of form *
* BELEG_INITIALISIEREN *
* *
*---------------------------------------------------------------------*
FORM USEREXIT_REFRESH_DOCUMENT.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""$"$\SE:(1) Form USEREXIT_REFRESH_DOCUMENT, Start
A
*$*$-Start: (1)--------------------------------------------------------------
-------------------$*$*
ENHANCEMENT 1 ZPP_ENH_PROD_ORDER_IDOC. "active version
include ZI_PP_PROD_ORDR_SEND_QUINTIQ.
ENDENHANCEMENT.
*$*$-End: (1)--------------------------------------------------------------
-------------------$*$*
* clear: zz45a.
* refresh: zzitemtab.
ENDFORM.
*eject
=================================================================
*&---------------------------------------------------------------------*
*& Include ZI_PP_PROD_ORDR_SEND_QUINTIQ
*&---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Modification : {To trigger IDOC for production order from Sales Order
* program RCCLORD is called. in Production Order
* there is no o/p type concept for IDOC trigger.
* We have tried Event but that is also not working as req
uirement is
* to trigger IDOC when Prod created or change }
* Modified by : Bhaskar Patil
* Date (dd-mm-yyyy): 10-03-2016
* Reason : NA
* Searchkey : DV9K901857
* Transportnumber : DV9K901857
*---------------------------------------------------------------------*
* REVISION HISTORY-----------------------------------------------------*
* REVISION NO: 1. REFERENCE NO: Ticket 594623 *
* DEVELOPER : Arunodaya Biswas *
* TRANSPORT : DV9K902949 *
* DESCRIPTION: Implement Wait for database commit *
* DATE : 20.04.2016 *
* SEARCH KEY : T_594623 *
*&---------------------------------------------------------------------*
*------------L O C A L T Y P E S I N I T I A L L Z A T I O N------------
-*
TYPES : BEGIN OF lty_aufnr,
sign TYPE c LENGTH 1,
option TYPE c LENGTH 2,
low TYPE aufnr,
high TYPE aufnr,
END OF lty_aufnr.
*-------------------C O N S T A N T D E C L A R A T I O N------------*
CONSTANTS : lc_sign(1) TYPE c VALUE 'I',
lc_option(2) TYPE c VALUE 'EQ',
lc_dev TYPE logsys VALUE 'SAPPID',
lc_test TYPE logsys VALUE 'SAPPIQ',
lc_prod TYPE logsys VALUE 'SAPPIP',
lc_mestyp TYPE edi_mestyp VALUE 'ZLOIPRO_100216',
lc_auart TYPE auart VALUE 'ZPN1',
lc_dv9 TYPE sysid VALUE 'DV9',
lc_ts9 TYPE sysid VALUE 'TS9',
lc_pr9 TYPE sysid VALUE 'PR9',
lc_zpc1 TYPE auart VALUE 'ZPC1'.
*------------------D A T A I N I T I A L L Z A T I O N-----------------*
REFRESH : lt_aufnr,
lt_werks.
CLEAR : lwa_aufnr,
lwa_werks,
lv_logsys.
CLEAR : gs_caufvd.
*-------------------------------------------------------------------------*
WAIT UP TO 5 SECONDS."++T_594623
IMPORT gs_caufvd FROM MEMORY ID 'PRODORD'.
*-------------------------------------------------------------------------*
IF gs_caufvd-auart EQ lc_auart.
IF sy-sysid EQ lc_dv9.
lv_logsys = lc_dev.
ELSEIF sy-sysid EQ lc_ts9.
lv_logsys = lc_test.
ELSEIF sy-sysid EQ lc_pr9.
lv_logsys = lc_prod.
ELSE.
lv_logsys = space.
ENDIF.
* Assign Plant values
lwa_werks-sign = lc_sign.
lwa_werks-option = lc_option.
lwa_werks-low = gs_caufvd-werks.
APPEND lwa_werks TO lt_werks.
CLEAR : lwa_werks.
* Assign Production order
lwa_aufnr-sign = lc_sign.
lwa_aufnr-option = lc_option.
lwa_aufnr-low = gs_caufvd-aufnr.
APPEND lwa_aufnr TO lt_aufnr.
CLEAR : lwa_aufnr.
* Assign Material Number
lwa_matnr-sign = lc_sign.
lwa_matnr-option = lc_option.
lwa_matnr-low = gs_caufvd-matnr.
APPEND lwa_matnr TO lt_matnr.
CLEAR : lwa_matnr.
CLEAR : lwa_aufnr,
lwa_werks,
lv_logsys.
CLEAR : gs_caufvd.
ENDIF.