You are on page 1of 6

************************************************************************

* LSM Workbench: Data Conversion Program


* Program:
/1CADMC/SAP_LSMW_CONV_00000012
* Date:
17.05.2012
* Time:
16:08:52
* User:
NEELAMD
* Project:
FGUPLOAD
* Subproject: FGUPLOAD
* Object:
FGUPLOAD
************************************************************************
report /1CADMC/SAP_LSMW_CONV_00000012
message-id /sapdmc/lsmw.
* Global data definitions and table declarations
include:
/SAPDMC/SAP_LSMW_INC_GLOBALS.
* Additional data definitions and table declarations
include:
/sapdmc/sap_lsmw_conv_data.
* Target structure definitions
data:
begin of ZMM01 occurs 0,
TABNAME(000030) type C,
TCODE(000020) type C,
MATNR(000018) type C,
MBRSH(000001) type C,
MTART(000004) type C,
KZSEL_01(000001) type C,
KZSEL_03(000001) type C,
KZSEL_04(000001) type C,
WERKS(000004) type C,
LGORT(000004) type C,
VKORG(000004) type C,
VTWEG(000002) type C,
MAKTX(000040) type C,
SKTOF(000001) type C,
TAXKM_01(000001) type C,
MTPOS(000004) type C,
MTVFP(000002) type C,
LADGR(000004) type C,
PRCTR(000010) type C,
STEUC(000016) type C,
DISMM(000002) type C,
BESKZ(000001) type C,
PERKZ(000001) type C,
IPRKZ(000001) type C,
BKLAS(000004) type C,
VPRSV(000001) type C,
PEINH(000006) type C,
EKALR(000001) type C,
LOSGR(000017) type C,
end of ZMM01 .
data:
init_ZMM01 like ZMM01,
prev_ZMM01 like ZMM01.
* Source structure definitions
data:

begin of LSMW_MMMASTER,
MATNR(018) type C,
MBRSH(001) type C,
MTART(004) type C,
WERKS(004) type C,
LGORT(004) type C,
VKORG(004) type C,
VTWEG(002) type C,
TAXKM_01(001) type C,
MTPOS(004) type C,
MTVFP(002) type C,
LADGR(004) type C,
PRCTR(010) type C,
STEUC(016) type C,
DISMM(002) type C,
BESKZ(001) type C,
PERKZ(001) type C,
IPRKZ(001) type C,
BKLAS(004) type C,
VPRSV(001) type C,
PEINH(005) type C,
EKALR(001) type C,
LOSGR(013) type C,
end of LSMW_MMMASTER.
data:
begin of MMMASTER occurs 0.
include structure LSMW_MMMASTER.
data: recnr_000001 type i.
data:
end of MMMASTER.
* Counters
data:
g_cnt_MMMASTER type i.
* Counter ct_xxxxxxxxxx: number of transferred records
data:
ct_ZMM01 type i,
cs_ZMM01 type i.
parameters:
p_filept no-display,
p_trfcpt no-display,
p_packge(5) type n no-display.
* Select-option for wildcard value in file names
selection-screen begin of block selopts3
with frame title text-003.
select-options:
so_wldcd for /sapdmc/lsofiw-wildcardvalue no-display.
selection-screen end of block selopts3.
initialization.
* Object identifer
g_project = 'FGUPLOAD
g_subproj = 'FGUPLOAD
g_object = 'FGUPLOAD

'.
'.
'.

g_objecttype = '02'.
start-of-selection.
* Initializations
perform initializations.
* Reset counters and flags
perform reset_counters_and_flags.
* Reset tables
perform reset_tables.
* Create initial structures with nodata characters
perform create_initial_structures.
* Execute data conversion.
perform execute_data_conversion.
* Final message
perform final_message.
* Close files
perform close_files.
* Write protocol.
perform write_protocol.
* End program
exit.
* Form Routines
include:
/sapdmc/sap_lsmw_conv_forms,
/sapdmc/sap_lsmw_conv_prot.
*&---------------------------------------------------------------------*
*&
Form execute_data_conversion
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form execute_data_conversion.
data: struc_length type i.
do.
perform read_next_record.
if g_flg_end_of_file = yes. exit. endif.
case g_record.
when 'MMMASTER'.
if g_flg_convert_transaction = yes.
perform convert_transaction.
perform clear_source_tables.
else.
g_flg_convert_transaction = yes.
endif.
assign gs_buffer-data to <g_buffer_to_struc>
casting like lsmw_MMMASTER.

move-corresponding <g_buffer_to_struc> to MMMASTER.


MMMASTER-recnr_000001 = g_cnt_records_read.
append MMMASTER.
add 1 to g_cnt_MMMASTER.
add 1 to g_cnt_transactions_read.
when others.
* perform insert_message using ... .
endcase.
if ( so_tcntr-option = 'BT' and
g_cnt_transactions_read > so_tcntr-high ) or
( so_tcntr-option = 'EQ' and
g_cnt_transactions_read > so_tcntr-low ).
exit.
endif.
enddo.
* Process last transaction.
perform convert_transaction.
perform clear_source_tables.
endform.

"execute_data_conversion

*&---------------------------------------------------------------------*
*&
Form convert_transaction
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form convert_transaction.
check so_tcntr.
loop at MMMASTER.
perform convert_0001.
ENDLOOP.

" ZMM01

* End of transaction
transfer_transaction.
endform.

"convert_transaction

*&---------------------------------------------------------------------*
*&
Form clear_source_tables
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form clear_source_tables.
clear MMMASTER[].
endform.

"clear_source_tables

*&---------------------------------------------------------------------*
*&
Form create_initial_structures
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form create_initial_structures.
perform initialize_with_nodata using

'ZMM01' init_ZMM01.
endform.

"create_initial_structures

*&---------------------------------------------------------------------*
*&
Form convert_0001
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form convert_0001.
" ZMM01
check g_skip_transaction = no.
g_skip_record = no.
g_record = 'ZMM01'.
* --- __BEGIN_OF_RECORD__
ZMM01 = INIT_ZMM01.
* --- ZMM01-TABNAME
ZMM01-TABNAME = 'ZMM01'.
* --- ZMM01-TCODE
ZMM01-TCODE = 'MM01'.
* --- ZMM01-MATNR
ZMM01-MATNR = MMMASTER-MATNR.
* --- ZMM01-MBRSH
ZMM01-MBRSH = MMMASTER-MBRSH.
* --- ZMM01-MTART
ZMM01-MTART = MMMASTER-MTART.
* --- ZMM01-KZSEL_01
ZMM01-KZSEL_01 = 'X'.
* --- ZMM01-KZSEL_03
ZMM01-KZSEL_03 = 'X'.
* --- ZMM01-KZSEL_04
ZMM01-KZSEL_04 = 'X'.
* --- ZMM01-WERKS
ZMM01-WERKS = MMMASTER-WERKS.
* --- ZMM01-LGORT
ZMM01-LGORT = MMMASTER-LGORT.
* --- ZMM01-VKORG
ZMM01-VKORG = MMMASTER-VKORG.
* --- ZMM01-VTWEG
ZMM01-VTWEG = MMMASTER-VTWEG.
* --- ZMM01-TAXKM_01
ZMM01-TAXKM_01 = MMMASTER-TAXKM_01.
* --- ZMM01-MTPOS

ZMM01-MTPOS = MMMASTER-MTPOS.
* --- ZMM01-MTVFP
ZMM01-MTVFP = MMMASTER-MTVFP.
* --- ZMM01-LADGR
ZMM01-LADGR = MMMASTER-LADGR.
* --- ZMM01-PRCTR
ZMM01-PRCTR = MMMASTER-PRCTR.
* --- ZMM01-STEUC
ZMM01-STEUC = MMMASTER-STEUC.
* --- ZMM01-DISMM
ZMM01-DISMM = MMMASTER-DISMM.
* --- ZMM01-BESKZ
ZMM01-BESKZ = MMMASTER-BESKZ.
* --- ZMM01-PERKZ
ZMM01-PERKZ = MMMASTER-PERKZ.
* --- ZMM01-IPRKZ
ZMM01-IPRKZ = MMMASTER-IPRKZ.
* --- ZMM01-BKLAS
ZMM01-BKLAS = MMMASTER-BKLAS.
* --- ZMM01-VPRSV
ZMM01-VPRSV = MMMASTER-VPRSV.
* --- ZMM01-PEINH
ZMM01-PEINH = MMMASTER-PEINH.
* --- ZMM01-EKALR
ZMM01-EKALR = MMMASTER-EKALR.
* --- ZMM01-LOSGR
ZMM01-LOSGR = MMMASTER-LOSGR.
* --- __END_OF_RECORD__
transfer_record.
g_skip_record = no.
endform.

"convert_0001