Posted: Sun Oct 14, 2007 8:30 pm Post subject: Create Equipment using 'BAPI_EQUI_CREATE'
Requirement:
Create Equipment along with the long text by uploading data from a tab delimited file.
Processing:
This program is to upload equipment master data from a tab delimited file using BAPI 'BAPI_EQUI_CREATE'. The first line of input file will have the header description of data-fields and hence the fiirst line on the file will will not be processed. Further, In case of error the progran also creates an error datafile containing all the error records. This file will be created in the same input directory but name of the file will be .err<.txt>. At the end of the program-run a report containing record number, equipment number ( if there ), status and message will be displayed. This report will have the information for error as well as successful records.
********************************************************************
* This program is used to upload equipment master data from a tab
* delimited file.
*
* The first line of input file will have the header description of
* data-fields and hence the fiirst line on the file will will not
* be processed.
*
* Further all the fields ( or at least the numeric fields like 0010 )
* should be specified as "text" while formatting the data in Excel file
* or else it will be uploaded as 10 and hence SAP might reject these
* records.
* Further, In case of error the progran also creates an error datafile
* containing all the error records. This file will be created in the
* same input directory but name of the file will be
*.err<.txt>.
* At the end of the program-run a report containing record number,
* equipment number ( if there ), status and message will be displayed.
* This report will have the information for error as well as successful
* records.
data : gv_file_name LIKE rlgrap-filename.
DATA: BEGIN OF gt_upload OCCURS 0,
rec(3000) TYPE c,
END OF gt_upload.
DATA: BEGIN OF gt_header_fields OCCURS 0,
rec(3000) TYPE c,
END OF gt_header_fields.
data: Begin of gt_equipment_data occurs 0,
EQUI_NUMBER TYPE BAPI_ITOB_PARMS-EQUIPMENT,
VALID_DATE TYPE BAPI_ITOB_PARMS-INST_DATE,
FUNCLOC TYPE BAPI_ITOB_EQ_INSTALL-FUNCLOC,
SUPEQUI TYPE BAPI_ITOB_EQ_INSTALL-SUPEQUI,
MATERIAL TYPE BAPI_ITOB_EQ_ONLY-MATERIAL,
SERIALNO TYPE BAPI_ITOB_EQ_ONLY-SERIALNO,
EQUICATGRY TYPE BAPI_ITOB_EQ_ONLY-EQUICATGRY,
BATCH TYPE BAPI_ITOB_EQ_ONLY-BATCH,
READ_SUPEQ TYPE BAPI_ITOB_EQ_ONLY-READ_SUPEQ,
READ_FLOC TYPE BAPI_ITOB_EQ_ONLY-READ_FLOC,
OBJECTTYPE TYPE BAPI_ITOB-OBJECTTYPE,
OBJ_SIZE TYPE BAPI_ITOB-OBJ_SIZE,
OBJ_WEIGHT(16) TYPE C, "BAPI_ITOB-OBJ_WEIGHT,
UNIT_OF_WT TYPE BAPI_ITOB-UNIT_OF_WT,
MANFACTURE TYPE BAPI_ITOB-MANFACTURE,
MANCOUNTRY TYPE BAPI_ITOB-MANCOUNTRY,
COUNTR_ISO TYPE BAPI_ITOB-COUNTR_ISO,
MANSERNO TYPE BAPI_ITOB-MANSERNO,
MANMODEL TYPE BAPI_ITOB-MANMODEL,
CONSTYEAR TYPE BAPI_ITOB-CONSTYEAR,
CONSTMONTH TYPE BAPI_ITOB-CONSTMONTH,
START_FROM TYPE BAPI_ITOB-START_FROM,
PLANPLANT TYPE BAPI_ITOB-PLANPLANT,
MANPARNO TYPE BAPI_ITOB-MANPARNO,
PLANGROUP TYPE BAPI_ITOB-PLANGROUP,
CATPROFILE TYPE BAPI_ITOB-CATPROFILE,
WCTR_PLANT TYPE BAPI_ITOB-MAINTPLANT,
WORK_CTR(8) TYPE C, "BAPI_ITOB-WORK_CTR,
DESCRIPT TYPE BAPI_ITOB-DESCRIPT,
ABCINDIC TYPE BAPI_ITOB-ABCINDIC,
SORTFIELD TYPE BAPI_ITOB-SORTFIELD,
MAINTPLANT TYPE BAPI_ITOB-MAINTPLANT,
MAINTLOC TYPE BAPI_ITOB-MAINTLOC,
PP_WKCTR(8) TYPE C, "BAPI_ITOB-PP_WKCTR,
COSTCENTER TYPE BAPI_ITOB-COSTCENTER,
COMP_CODE TYPE BAPI_ITOB-COMP_CODE,
LONG_TEXT(2500) TYPE C,
end of gt_equipment_data.
data: Begin of gt_equipment_error_data occurs 0,
EQUI_NUMBER TYPE BAPI_ITOB_PARMS-EQUIPMENT,
VALID_DATE TYPE BAPI_ITOB_PARMS-INST_DATE,
FUNCLOC TYPE BAPI_ITOB_EQ_INSTALL-FUNCLOC,
SUPEQUI TYPE BAPI_ITOB_EQ_INSTALL-SUPEQUI,
MATERIAL TYPE BAPI_ITOB_EQ_ONLY-MATERIAL,
SERIALNO TYPE BAPI_ITOB_EQ_ONLY-SERIALNO,
EQUICATGRY TYPE BAPI_ITOB_EQ_ONLY-EQUICATGRY,
BATCH TYPE BAPI_ITOB_EQ_ONLY-BATCH,
READ_SUPEQ TYPE BAPI_ITOB_EQ_ONLY-READ_SUPEQ,
READ_FLOC TYPE BAPI_ITOB_EQ_ONLY-READ_FLOC,
OBJECTTYPE TYPE BAPI_ITOB-OBJECTTYPE,
OBJ_SIZE TYPE BAPI_ITOB-OBJ_SIZE,
OBJ_WEIGHT(16) TYPE C, "BAPI_ITOB-OBJ_WEIGHT,
UNIT_OF_WT TYPE BAPI_ITOB-UNIT_OF_WT,
MANFACTURE TYPE BAPI_ITOB-MANFACTURE,
MANCOUNTRY TYPE BAPI_ITOB-MANCOUNTRY,
COUNTR_ISO TYPE BAPI_ITOB-COUNTR_ISO,
MANSERNO TYPE BAPI_ITOB-MANSERNO,
MANMODEL TYPE BAPI_ITOB-MANMODEL,
CONSTYEAR TYPE BAPI_ITOB-CONSTYEAR,
CONSTMONTH TYPE BAPI_ITOB-CONSTMONTH,
START_FROM TYPE BAPI_ITOB-START_FROM,
PLANPLANT TYPE BAPI_ITOB-PLANPLANT,
MANPARNO TYPE BAPI_ITOB-MANPARNO,
PLANGROUP TYPE BAPI_ITOB-PLANGROUP,
CATPROFILE TYPE BAPI_ITOB-CATPROFILE,
WCTR_PLANT TYPE BAPI_ITOB-MAINTPLANT,
WORK_CTR(8) TYPE C, "BAPI_ITOB-WORK_CTR,
DESCRIPT TYPE BAPI_ITOB-DESCRIPT,
ABCINDIC TYPE BAPI_ITOB-ABCINDIC,
SORTFIELD TYPE BAPI_ITOB-SORTFIELD,
MAINTPLANT TYPE BAPI_ITOB-MAINTPLANT,
MAINTLOC TYPE BAPI_ITOB-MAINTLOC,
PP_WKCTR(8) TYPE C, "BAPI_ITOB-PP_WKCTR,
COSTCENTER TYPE BAPI_ITOB-COSTCENTER,
COMP_CODE TYPE BAPI_ITOB-COMP_CODE,
LONG_TEXT(2500) TYPE C,
end of gt_equipment_error_data.
data: Begin of gt_equipment_error_rep occurs 0,
EQUI_NUMBER TYPE BAPI_ITOB_PARMS-EQUIPMENT,
VALID_DATE TYPE BAPI_ITOB_PARMS-INST_DATE,
FUNCLOC TYPE BAPI_ITOB_EQ_INSTALL-FUNCLOC,
SUPEQUI TYPE BAPI_ITOB_EQ_INSTALL-SUPEQUI,
MATERIAL TYPE BAPI_ITOB_EQ_ONLY-MATERIAL,
SERIALNO TYPE BAPI_ITOB_EQ_ONLY-SERIALNO,
EQUICATGRY TYPE BAPI_ITOB_EQ_ONLY-EQUICATGRY,
BATCH TYPE BAPI_ITOB_EQ_ONLY-BATCH,
READ_SUPEQ TYPE BAPI_ITOB_EQ_ONLY-READ_SUPEQ,
READ_FLOC TYPE BAPI_ITOB_EQ_ONLY-READ_FLOC,
OBJECTTYPE TYPE BAPI_ITOB-OBJECTTYPE,
OBJ_SIZE TYPE BAPI_ITOB-OBJ_SIZE,
OBJ_WEIGHT TYPE BAPI_ITOB-OBJ_WEIGHT,
UNIT_OF_WT TYPE BAPI_ITOB-UNIT_OF_WT,
MANFACTURE TYPE BAPI_ITOB-MANFACTURE,
MANCOUNTRY TYPE BAPI_ITOB-MANCOUNTRY,
COUNTR_ISO TYPE BAPI_ITOB-COUNTR_ISO,
MANSERNO TYPE BAPI_ITOB-MANSERNO,
MANMODEL TYPE BAPI_ITOB-MANMODEL,
CONSTYEAR TYPE BAPI_ITOB-CONSTYEAR,
CONSTMONTH TYPE BAPI_ITOB-CONSTMONTH,
START_FROM TYPE BAPI_ITOB-START_FROM,
PLANPLANT TYPE BAPI_ITOB-PLANPLANT,
MANPARNO TYPE BAPI_ITOB-MANPARNO,
PLANGROUP TYPE BAPI_ITOB-PLANGROUP,
CATPROFILE TYPE BAPI_ITOB-CATPROFILE,
WCTR_PLANT TYPE BAPI_ITOB-MAINTPLANT,
WORK_CTR(8) TYPE C, "BAPI_ITOB-WORK_CTR,
DESCRIPT TYPE BAPI_ITOB-DESCRIPT,
ABCINDIC TYPE BAPI_ITOB-ABCINDIC,
SORTFIELD TYPE BAPI_ITOB-SORTFIELD,
MAINTPLANT TYPE BAPI_ITOB-MAINTPLANT,
MAINTLOC TYPE BAPI_ITOB-MAINTLOC,
PP_WKCTR(8) TYPE C, "BAPI_ITOB-PP_WKCTR,
COSTCENTER TYPE BAPI_ITOB-COSTCENTER,
COMP_CODE TYPE BAPI_ITOB-COMP_CODE,
MESSAGE TYPE bad_patch-descript,
STATUS(10) TYPE C,
RECORD TYPE i,
end of gt_equipment_error_rep.
* ALV stuff
type-pools: slis.
data: gt_fieldcat type slis_t_fieldcat_alv,
gs_layout type slis_layout_alv,
gt_sort type slis_t_sortinfo_alv.
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
PERFORM authorization_check.
PERFORM get_file_name using 'P_INFILE'
changing gv_file_name.
START-OF-SELECTION.
PERFORM read_input_file_from_pc tables gt_upload
using p_infile.
END-OF-SELECTION.
PERFORM write_error_file_to_pc tables gt_equipment_error_data
using p_infile.
perform alv_grid.
*&---------------------------------------------------------------------*
*& Form get_file_name
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_file_name using x_file_field_name
changing y_file_name_with_path.
data : lv_file_path type rlgrap-filename,
lv_file_name type rlgrap-filename.
PERFORM read_screen_values USING x_file_field_name
CHANGING y_file_name_with_path.
PERFORM split_path USING y_file_name_with_path
CHANGING lv_file_path
lv_file_name.
ENDFORM. " get_file_name
*&--------------------------------------------------------------------*
*& Form read_screen_values
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->P_FIELD text
* -->P_VALUE text
*---------------------------------------------------------------------*
FORM read_screen_values USING x_field
CHANGING y_value.
DATA: lv_dynpname LIKE d020s-prog,
lv_dynpnumb LIKE d020s-dnum.
DATA: BEGIN OF lt_dynpvaluetab OCCURS 1.
INCLUDE STRUCTURE dynpread.
DATA: END OF lt_dynpvaluetab.
READ TABLE lt_dynpvaluetab INDEX 1.
MOVE: lt_dynpvaluetab-fieldvalue TO y_value.
ENDIF.
ENDFORM. " read_screen_values
*&--------------------------------------------------------------------*
*& Form split_path
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->P_WHOLE text
* -->P_PATH text
* -->P_FNAME text
* -->P_SCHARS text
*---------------------------------------------------------------------*
FORM split_path USING x_file_name_with_path
CHANGING y_file_path
y_file_name.
DATA: lv_length TYPE i,
lv_cpos TYPE i.
check not x_file_name_with_path is initial.
lv_length = strlen( x_file_name_with_path ).
lv_cpos = lv_length.
DO lv_length times.
lv_cpos = lv_cpos - 1.
check x_file_name_with_path+lv_cpos(1) eq '\'.
exit.
ENDDO.
y_file_path = x_file_name_with_path(lv_cpos).
lv_cpos = lv_cpos + 1.
y_file_name = x_file_name_with_path+lv_cpos(lv_length).
ENDFORM. " split_path
*&---------------------------------------------------------------------*
*& Form read_input_file_from_pc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM read_input_file_from_pc tables yt_upload
using x_infile.
* Use WS_Upload if file is located on the local PC.
* WS_Upload only works in foreground
IF sy-batch EQ 'X'.
WRITE: text-002.
<* ERROR: Unable to upload locally stored files when running in
* background
ELSE.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = x_infile
filetype = 'ASC'
TABLES
data_tab = yt_upload
EXCEPTIONS
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
gui_refuse_filetransfer = 8
OTHERS = 9.
* Status of upload
CASE sy-subrc.
WHEN 0.
WHEN OTHERS.
* Upload unsuccessful - error message
MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDCASE.
ENDIF.
IF yt_upload[] is initial.
MESSAGE E079(z1) with x_infile.
ENDIF.
ENDFORM. " read_input_file_from_pc
*&---------------------------------------------------------------------*
*& Form prepare_itab_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_UPLOAD text
* <--P_GT_EQUIPMENT_DATA text
*----------------------------------------------------------------------*
FORM prepare_itab_data
TABLES XT_UPLOAD STRUCTURE GT_UPLOAD
YT_EQUIPMENT_DATA STRUCTURE GT_EQUIPMENT_DATA.
constants :
lc_tab type x value '09'.
data :
lv_length type i.
loop at xt_upload.
* Skip the header line descriptions in the file.
if sy-tabix eq 1.
SPLIT XT_UPLOAD at lc_tab into table gt_header_fields.
continue.
endif.
lv_length = strlen( yt_equipment_data-CONSTMONTH ).
IF lv_length eq 1.
concatenate '0' yt_equipment_data-CONSTMONTH
into yt_equipment_data-CONSTMONTH.
endif.
* Populate other values ( system variables/constants - not from file )
APPEND yt_equipment_data.
endloop.
ENDFORM. " prepare_itab_data
*&---------------------------------------------------------------------*
*& Form call_bapi_create_equipment
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->XT_EQUIPMENT_DATA text
*----------------------------------------------------------------------*
FORM call_bapi_create_equipment
TABLES
XT_EQUIPMENT_DATA STRUCTURE GT_EQUIPMENT_DATA
XT_EQUIPMENT_error_DATA STRUCTURE GT_EQUIPMENT_DATA
XT_EQUIPMENT_error_rep STRUCTURE GT_EQUIPMENT_error_rep.
data :
lv_BAPI_ITOB type BAPI_ITOB,
lv_BAPI_ITOB_EQ_ONLY type BAPI_ITOB_EQ_ONLY,
lv_BAPI_ITOB_EQ_INSTALL type BAPI_ITOB_EQ_INSTALL,
lv_BAPI_ITOBX type BAPI_ITOBX,
lv_BAPI_ITOB_EQ_ONLYX type BAPI_ITOB_EQ_ONLYX,
lv_valid_date type sy-datum,
lv_return like bapiret2,
lv_record_no type sy-index,
lv_edit_type(6) type c,
lv_no_error_flag type c.
loop at XT_EQUIPMENT_DATA.
CLEAR : lv_return,
lv_BAPI_ITOB,
lv_BAPI_ITOB_EQ_ONLY,
lv_BAPI_ITOB_EQ_INSTALL,
lv_valid_date.
lv_record_no = sy-tabix.
PERFORM get_object_id_of_workcentres
tables xt_EQUIPMENT_error_DATA
xT_EQUIPMENT_error_rep
using lv_record_no
CHANGING XT_EQUIPMENT_DATA
lv_no_error_flag.
* Error encuntered in work centre id determination.
IF lv_no_error_flag is initial.
continue.
ENDIF.
* Check if equipment number was specified in file.
if XT_EQUIPMENT_DATA-EQUI_NUMBER is initial.
lv_edit_type = 'CREATE'.
else.
lv_edit_type = 'CHANGE'.
endif.
* Save Long Text for Equipment.
check not XT_EQUIPMENT_DATA-long_text is initial.
PERFORM save_long_text using XT_EQUIPMENT_DATA-equi_number
XT_EQUIPMENT_DATA-long_text.
endif.
endloop.
ENDFORM. " call_bapi_create_equipment
*&---------------------------------------------------------------------*
*& Form populate_bapi_structures
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->XT_EQUIPMENT_DATA text
* <--Y_BAPI_ITOB text
* <--Y_BAPI_ITOB_EQ_ONLY text
* <--Y_BAPI_ITOB_EQ_INSTALL text
* <--Y_VALID_DATE text
*----------------------------------------------------------------------*
FORM populate_bapi_structures
USING XT_EQUIPMENT_DATA STRUCTURE GT_EQUIPMENT_DATA
x_edit_type TYPE C
CHANGING y_BAPI_ITOB STRUCTURE BAPI_ITOB
y_BAPI_ITOB_EQ_ONLY STRUCTURE BAPI_ITOB_EQ_ONLY
y_BAPI_ITOB_EQ_INSTALL STRUCTURE BAPI_ITOB_EQ_INSTALL
y_VALID_DATE
y_BAPI_ITOBX STRUCTURE BAPI_ITOBX
y_BAPI_ITOB_EQ_ONLYX STRUCTURE BAPI_ITOB_EQ_ONLYX.
move-corresponding XT_EQUIPMENT_DATA to y_BAPI_ITOB.
move-corresponding XT_EQUIPMENT_DATA to y_BAPI_ITOB_EQ_ONLY.
move-corresponding XT_EQUIPMENT_DATA to y_BAPI_ITOB_EQ_INSTALL.
y_VALID_DATE = XT_EQUIPMENT_DATA-VALID_DATE.
ENDFORM. " populate_bapi_structures
*&---------------------------------------------------------------------*
*& Form write_error_file_to_pc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_EQUIPMENT_ERROR_DATA text
*----------------------------------------------------------------------*
FORM write_error_file_to_pc tables xt_download
using x_infile.
check not xt_download[] is initial.
replace '.' with '.err.' into x_infile.
*&---------------------------------------------------------------------*
*& Form alv_grid
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form alv_grid.
if gt_fieldcat[] is initial.
perform fieldcat_init.
perform layout_init.
perform sort_init.
endif.
perform grid_display.
endform.
*&---------------------------------------------------------------------*
*& Form layout_init
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form layout_init.
gs_layout-zebra = 'X'.
gs_layout-cell_merge = 'X'.
gs_layout-colwidth_optimize = 'X'.
gs_layout-no_vline = ' '.
gs_layout-totals_before_items = ' '.
endform. " layout_init
*&---------------------------------------------------------------------*
*& Form fieldcat_init
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form fieldcat_init.
data: ls_fieldcat type slis_fieldcat_alv.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'RECORD'.
ls_fieldcat-key = 'X'.
ls_fieldcat-reptext_ddic = 'Record Number'.
ls_fieldcat-outputlen = 10.
* Fix for ALV print bug,
* Set type to 'N' to stop corruption of printed ALV cell.
ls_fieldcat-inttype = 'N'.
append ls_fieldcat to gt_fieldcat.
*&---------------------------------------------------------------------*
*& Form sort_init
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form sort_init.
data: ls_sort type slis_sortinfo_alv.
endform.
*&---------------------------------------------------------------------*
*& Form grid_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form grid_display.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fieldcat
it_sort = gt_sort
i_default = ' '
i_save = 'X'
TABLES
t_outtab = gt_equipment_error_rep
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform.
*&---------------------------------------------------------------------*
*& Form authorization_check
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM authorization_check.
CALL FUNCTION 'AUTHORITY_CHECK_EQUI'
EXPORTING
TCODE = 'IE01'
EXCEPTIONS
NO_AUTHORITY_TCODE = 1
NO_AUTHORITY_BEGRP = 2
NO_AUTHORITY_IWERK = 3
NO_AUTHORITY_INGRP = 4
NO_AUTHORITY_SWERK = 5
NO_AUTHORITY_KOSTL = 6
NO_PROFILE_IN_USER_MASTER_DATA = 7
ERROR_IN_USER_MASTER_DATA = 8
OTHERS = 9.
IF SY-SUBRC <> 0.
message E078(z1).
ENDIF.
ENDFORM. " authorization_check
*&---------------------------------------------------------------------*
*& Form prepare_error_text
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->XT_RETURN text
* <--YT_EQUIPMENT_ERROR_REP_MESSAGE text
*----------------------------------------------------------------------*
FORM prepare_error_text USING X_RETURN TYPE BAPIRET2
CHANGING Y_MESSAGE TYPE bad_patch-descript.
* Convert the message
MOVE : x_return-id TO sy-msgid,
x_return-number TO sy-msgno,
x_return-message_v1 TO sy-msgv1,
x_return-message_v2 TO sy-msgv2,
x_return-message_v3 TO sy-msgv3,
x_return-message_v4 TO sy-msgv4.
ENDFORM. " prepare_error_text
*&---------------------------------------------------------------------*
*& Form save_long_text
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->x_EQUI_NUMBER text
* -->x_long_text text
*----------------------------------------------------------------------*
FORM save_long_text USING x_EQUI_NUMBER
x_long_text.
data :
lt_long_text type table of TLINE with header line,
lv_text_length type i,
lv_loop_times type i,
lv_char_pos_last type i,
lv_char_pos_curr type i,
lv_header type thead.
* For Error data file.
modify gt_equipment_error_data from gt_equipment_data.
gt_equipment_error_rep-status = 'Error'.
modify GT_EQUIPMENT_error_rep transporting MESSAGE STATUS
where EQUI_NUMBER = x_EQUI_NUMBER.
ELSE.
COMMIT WORK.
ENDIF.
ENDFORM. " save_long_text
*&---------------------------------------------------------------------*
*& Form get_object_id_of_workcentres
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_object_id_of_workcentres
TABLES
yt_EQUIPMENT_error_DATA structure gt_equipment_error_DATA
YT_EQUIPMENT_error_rep structure gT_EQUIPMENT_error_rep
using value(x_record_no) type sy-index
CHANGING
x_equipment_data structure gt_equipment_data
y_no_error_flag type c.
data : lv_main_work_centre like gt_equipment_data-WORK_CTR,
lv_plan_work_centre like gt_equipment_data-PP_WKCTR.
y_no_error_flag = 'X'.
* Get Object ID of Work centre using work centre and plant.
IF not x_equipment_data-WORK_CTR is initial.
SELECT SINGLE OBJID
INTO lv_main_work_centre
FROM CRHD
WHERE objty = 'A'
AND arbpl = x_equipment_data-WORK_CTR
AND werks = x_equipment_data-WCTR_PLANT.
if sy-subrc <> 0.
y_no_error_flag = ' '.
* For Error data file.
append x_EQUIPMENT_data to YT_EQUIPMENT_error_DATA.
* For Error reporting.
YT_EQUIPMENT_error_rep = x_EQUIPMENT_data.
CONCATENATE
'Work Centre ID is not maintained for Maint Work center' space
x_equipment_data-WORK_CTR space ' and ' space
'Plant ' space x_equipment_data-MAINTPLANT
into YT_EQUIPMENT_error_rep-MESSAGE.
SELECT SINGLE OBJID
INTO lv_plan_work_centre
FROM CRHD
WHERE objty = 'A'
AND arbpl = x_equipment_data-PP_WKCTR
AND werks = x_equipment_data-WCTR_PLANT.
if sy-subrc <> 0.
y_no_error_flag = ' '.
y_no_error_flag = ' '.
* For Error data file.
append x_EQUIPMENT_data to YT_EQUIPMENT_error_DATA.
* For Error reporting.
YT_EQUIPMENT_error_rep = x_EQUIPMENT_data.
CONCATENATE
'Work Centre ID is not maintained for Plan Work center ' space
x_equipment_data-PP_WKCTR space ' and ' space
'Plant ' space x_equipment_data-PLANPLANT
into YT_EQUIPMENT_error_rep-MESSAGE.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.