0% found this document useful (0 votes)
151 views

SAPt Item Upload Programme

This document provides a summary of a program called ZALM_MAINT_ITEM_UPLOAD_PROGRAM that uploads maintenance item data from an Excel file into SAP. The program includes data declarations to define internal tables for the Excel data and maintenance item data. It also includes subroutines to fill these tables by extracting data from the Excel file, prepare BDC data to create maintenance items in transaction IP04, collect any messages from the process, and write any messages to the output.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views

SAPt Item Upload Programme

This document provides a summary of a program called ZALM_MAINT_ITEM_UPLOAD_PROGRAM that uploads maintenance item data from an Excel file into SAP. The program includes data declarations to define internal tables for the Excel data and maintenance item data. It also includes subroutines to fill these tables by extracting data from the Excel file, prepare BDC data to create maintenance items in transaction IP04, collect any messages from the process, and write any messages to the output.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

report zalm_maint_item_upload_program.

*********************************************************************
*Title : ZALM_MAINT_ITEM_UPLOAD_PROGRAM
*Developer : SHAFIUVLLAH M
*Date : 01.08.2007
*FS : P1143_FS_ESP_ALM_Single Cycle Plan_01
*TS : P1143_TS_ESP_ALM_Single Cycle Plan_01
*Description : BDC for creation of Maintenance item through Tcode : IP04
*
*Change history:
*********************************************************************
************************************************************************
* INCLUDES
************************************************************************
include <icon>.
************************************************************************
* DATA DECLARATIONS
************************************************************************
types: begin of x_itab ,
mptyp type rmipm-mptyp,
wstra type rmipm-wstra,
pstxt type rmipm-pstxt,
tplnr type riwo1-tplnr,
equnr type riwo1-equnr,
bautl type riwo1-bautl,
iwerk type rmipm-iwerk,
wpgrp type rmipm-wpgrp,
auart type rmipm-auart,
ilart type rmipm-ilart,
gewerk type rmipm-gewerk,
wergw type rmipm-wergw,
gsber type rmipm-gsber,
plnty type rmipm-plnty,
plnnr type rmipm-plnnr,
priok type rmipm-priok,
plnal type rmipm-plnal ,
end of x_itab.
types: begin of x_messages,
index type i,
msgtyp(1),
equnr(18),
tplnr(30),
message(120),
end of x_messages.
data : it_itab type standard table of x_itab ,
wa_itab type x_itab .
data x_ctuprms type ctu_params.
data it_bdcdata type standard table of bdcdata.
data : wa_bdcdata type bdcdata.

data: w_flname type ibipparms-path.


data: it_excel type standard table of alsmex_tabline,
wa_excel type alsmex_tabline.
data: it_msgtab type standard table of bdcmsgcoll .
data wa_msgtab type bdcmsgcoll.
data : it_messages type standard table of x_messages .
data wa_messages type x_messages.
data: w_index type i value 1.
constants : c_var(3) value '/00' ,
c_var1(3) value '=BU' .
************************************************************************
* SELECTION SCREEN
************************************************************************
selection-screen begin of block b1 with frame .
.
selection-screen : skip 1 .
parameters : p_flname type rlgrap-filename obligatory.
selection-screen end of block b1.
************************************************************************
* AT SELECTION SCREEN (F4 HELP)
************************************************************************
at selection-screen on value-request for p_flname.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
* FIELD_NAME = ' '
importing
file_name = w_flname.
p_flname = w_flname.

***********************************************************************
* START OF SELECTION
***********************************************************************
start-of-selection.
perform fill_it_itab.
perform execute_bdc.

*---------------------------------------------------------------------*
* FORM execute_bdc *
*---------------------------------------------------------------------*
* Sub-routine to create maintanince item.

*---------------------------------------------------------------------*
form execute_bdc.
data: w_bill(18).
perform fill_ctuprms.
loop at it_itab into wa_itab.
refresh it_bdcdata.
perform fill_bdcdata using :
'SAPLIWP3' '0200' 'X',
'BDC_OKCODE' c_var ' ',
'RMIPM-MPTYP' wa_itab-mptyp ' ',
'RMIPM-WSTRA' wa_itab-wstra ' ',
'SAPLIWP3' '0201' 'X',
'BDC_OKCODE' c_var ' ',
'RMIPM-PSTXT' wa_itab-pstxt '
'RMIPM-WSTRA' wa_itab-wstra '
'RIWO1-TPLNR' wa_itab-tplnr '
'RIWO1-EQUNR' wa_itab-equnr '
'RIWO1-BAUTL' wa_itab-bautl '
'RMIPM-IWERK' wa_itab-iwerk '
'RMIPM-WPGRP' wa_itab-wpgrp '
'RMIPM-AUART' wa_itab-auart '
'RMIPM-ILART' wa_itab-ilart '
'RMIPM-GEWERK' wa_itab-gewerk
'RMIPM-WERGW' wa_itab-wergw '
'RMIPM-GSBER' wa_itab-gsber '
'RMIPM-PLNTY' wa_itab-plnty '
'RMIPM-PLNNR' wa_itab-plnnr '
'RMIPM-PLNAL' wa_itab-plnal '

',
',
',
',
',
',
',
',
',
' ',
',
',
',
',
',

'SAPLIWP3' '0201' 'X',


'BDC_OKCODE' c_var ' ',
'RMIPM-PSTXT' wa_itab-pstxt '
*'RMIPM-WSTRA' wa_itab-WSTRA ' ',
'RIWO1-TPLNR' wa_itab-tplnr '
'RIWO1-EQUNR' wa_itab-equnr '
'RIWO1-BAUTL' wa_itab-bautl '
'RMIPM-IWERK' wa_itab-iwerk '
'RMIPM-WPGRP' wa_itab-wpgrp '
'RMIPM-AUART' wa_itab-auart '
'RMIPM-ILART' wa_itab-ilart '
'RMIPM-GEWERK' wa_itab-gewerk
'RMIPM-WERGW' wa_itab-wergw '
'RMIPM-GSBER' wa_itab-gsber
'RMIPM-PRIOK' wa_itab-priok
'RMIPM-PLNTY' wa_itab-plnty '
'RMIPM-PLNNR' wa_itab-plnnr '
'RMIPM-PLNAL' wa_itab-plnal '

',
',
',
',
',
',
',
',
' ',
',
' ',
' ',
',
',
',

'SAPLIWP3' '0201' 'X',


'BDC_OKCODE' c_var1 ' ',
'RMIPM-PSTXT' wa_itab-pstxt ' ',

*'RMIPM-WSTRA' wa_itab-WSTRA ' ',


'RIWO1-TPLNR' wa_itab-tplnr '
'RIWO1-EQUNR' wa_itab-equnr '
'RIWO1-BAUTL' wa_itab-bautl '
'RMIPM-IWERK' wa_itab-iwerk '
*'RMIPM-WPGR?' wa_itab-WPGRP ' ',
'RMIPM-AUART' wa_itab-auart '
'RMIPM-ILART' wa_itab-ilart '
'RMIPM-GEWERK' wa_itab-gewerk
'RMIPM-WERGW' wa_itab-wergw '
'RMIPM-GSBER' wa_itab-gsber
'RMIPM-PRIOK' wa_itab-priok
'RMIPM-PLNTY' wa_itab-plnty '
'RMIPM-PLNNR' wa_itab-plnnr '
'RMIPM-PLNAL' wa_itab-plnal '

',
',
',
',
',
',
' ',
',
' ',
' ',
',
',
'.

call transaction 'IP04' using it_bdcdata options from x_ctuprms


messages into it_msgtab.
clear wa_bdcdata.
refresh it_bdcdata.
perform collecit_messages.
endloop.

perform write_messages.
endform.
"execute_bdc
*&---------------------------------------------------------------------*
*& Form FILL_BDCDATA
*&---------------------------------------------------------------------*
* SUB-ROUTINE TO FILL BCDDATA FOR EXECUTION OF BDC
*----------------------------------------------------------------------*
* -->P_0414 text *
* -->P_0415 text *
* -->P_0416 text *
*----------------------------------------------------------------------*
form fill_bdcdata using val1
val2
val3.
clear wa_bdcdata.
if val3 = 'X'.
move val1 to wa_bdcdata-program.
move val2 to wa_bdcdata-dynpro.
move val3 to wa_bdcdata-dynbegin.
else.
move val1 to wa_bdcdata-fnam.
move val2 to wa_bdcdata-fval.
endif.
append wa_bdcdata to it_bdcdata.
endform. " FILL_BDCDATA
*&---------------------------------------------------------------------*
*& Form FILL_it_itab
*&---------------------------------------------------------------------*
*SUB-ROUTINE TO FILL DATA FROM A SPECIFIED FILE TO it_itab INTERNAL TABLE
*----------------------------------------------------------------------*
form fill_it_itab.
refresh it_excel.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'


exporting
filename
= p_flname
i_begin_col
= 2
i_begin_row
= 3
i_end_col
= 18
i_end_row
= 9999
tables
intern
= it_excel
exceptions
inconsistent_parameters = 1
upload_ole
= 2
others
= 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
**** Filling Data into Internal Tables IT_ITAB From Internal Table
**** it_excel.
clear wa_itab.
loop at it_excel into wa_excel.
case wa_excel-col .
when '1' .
wa_itab-mptyp = wa_excel-value.
when '2' .
move wa_excel-value to wa_itab-wstra.
when '3' .
wa_itab-pstxt = wa_excel-value.
when '4' .
wa_itab-tplnr = wa_excel-value.
when '5' .
wa_itab-equnr = wa_excel-value.
when '6' .
wa_itab-bautl = wa_excel-value.
when '7' .
wa_itab-iwerk = wa_excel-value.
when '8' .
wa_itab-wpgrp = wa_excel-value.
when '9' .
wa_itab-auart = wa_excel-value.
when '10' .
wa_itab-ilart = wa_excel-value.
when '11' .
wa_itab-gewerk = wa_excel-value.
when '12' .
wa_itab-wergw = wa_excel-value.
when '13' .
wa_itab-gsber = wa_excel-value.
when '14' .
wa_itab-plnty = wa_excel-value.
when '15' .
wa_itab-plnnr = wa_excel-value.
when '16' .
wa_itab-plnal = wa_excel-value.
when '17' .
wa_itab-priok = wa_excel-value.
endcase.

at end of row.
condense: wa_itab-mptyp , wa_itab-wstra,
wa_itab-pstxt , wa_itab-tplnr , wa_itab-equnr,
wa_itab-bautl , wa_itab-iwerk, wa_itab-wpgrp,
wa_itab-auart , wa_itab-ilart , wa_itab-gewerk,
wa_itab-wergw , wa_itab-gsber , wa_itab-plnty ,
wa_itab-plnnr , wa_itab-plnal , wa_itab-priok.
append wa_itab to it_itab.
clear wa_itab.
endat .
endloop.
endform. " FILL_it_itab
*&---------------------------------------------------------------------*
*& Form FILL_CTUPRMS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form fill_ctuprms.
clear x_ctuprms.
x_ctuprms-dismode = 'N'.
endform. " FILL_CTUPRMS
*&---------------------------------------------------------------------*
*& Form COLLECit_messages
*&---------------------------------------------------------------------*
* text
*-------------------------------------?--------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form collecit_messages.
data: w_msg(100).
loop at it_msgtab into wa_msgtab.
call function 'FORMAT_MESSAGE'
exporting
id
= wa_msgtab-msgid
lang = wa_msgtab-msgspra
no
= wa_msgtab-msgnr
v1
= wa_msgtab-msgv1
v2
= wa_msgtab-msgv2
importing
msg
= w_msg
exceptions
others = 0.
condense w_msg.
clear wa_messages.
wa_messages-index = w_index.
wa_messages-msgtyp = wa_msgtab-msgtyp.
wa_messages-message = w_msg.
wa_messages-equnr = wa_itab-equnr .

wa_messages-tplnr = wa_itab-tplnr.
append wa_messages to it_messages .
endloop.
w_index = w_index + 1.
refresh it_msgtab.
endform. " COLLECit_messages
*&---------------------------------------------------------------------*
*&
Form write_messages
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form write_messages .
loop at it_messages into wa_messages .
write:/1 sy-vline.
write : 2 wa_messages-index .
if wa_messages-msgtyp = 'S'.
write: 10 icon_green_light.
elseif wa_messages-msgtyp = 'E'.
write: 10 icon_red_light.
elseif wa_messages-msgtyp = 'W'.
write: 10 icon_yellow_light.
endif.
write: 20 sy-vline.
write : 30 wa_messages-equnr .
write: 48 sy-vline.
write : 49 wa_messages-tplnr .
write: 79 sy-vline.
write : 80 wa_messages-message .
write: 180 sy-vline.
write:/1 sy-vline.
uline 1(180).
endloop.

endform.

" write_messages

You might also like