You are on page 1of 5

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

* LSM Workbench: Data Conversion Program


* Program:
/1CADMC/SAP_LSMW_CONV_00000015
* Date:
02.09.2012
* Time:
21:58:47
* User:
NEERAJD
* Project:
MAT_REC1
* Subproject: MAT_REC1
* Object:
MAT_REC1
************************************************************************
report /1CADMC/SAP_LSMW_CONV_00000015
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 MAT_REC occurs 0,
TABNAME(000030) type C,
TCODE(000020) type C,
MATNR(000018) type C,
WERKS(000004) type C,
DISMM(000002) type C,
DISPO(000003) type C,
DISLS(000002) type C,
BESKZ(000001) type C,
FHORI(000003) type C,
end of MAT_REC .
data:
init_MAT_REC like MAT_REC,
prev_MAT_REC like MAT_REC.
* Source structure definitions
data:
begin of LSMW_MAT_CH,
MATNR(018) type C,
WERKS(004) type C,
DISMM(002) type C,
DISPO(003) type C,
DISLS(002) type C,
BESKZ(001) type C,
FHORI(003) type C,
end of LSMW_MAT_CH.
data:
begin of MAT_CH occurs 0.
include structure LSMW_MAT_CH.
data: recnr_000001 type i.
data:
end of MAT_CH.
* Counters
data:
g_cnt_MAT_CH type i.

* Counter ct_xxxxxxxxxx: number of transferred records


data:
ct_MAT_REC type i,
cs_MAT_REC 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 = 'MAT_REC1
g_subproj = 'MAT_REC1
g_object = 'MAT_REC1

'.
'.
'.

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 'MAT_CH'.
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_MAT_CH.
move-corresponding <g_buffer_to_struc> to MAT_CH.
MAT_CH-recnr_000001 = g_cnt_records_read.
append MAT_CH.
add 1 to g_cnt_MAT_CH.
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 MAT_CH.
perform convert_0001. " MAT_REC
ENDLOOP.

* End of transaction
transfer_transaction.
endform.

"convert_transaction

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

"clear_source_tables

*&---------------------------------------------------------------------*
*&
Form create_initial_structures
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form create_initial_structures.
perform initialize_with_nodata using
'MAT_REC' init_MAT_REC.
endform.

"create_initial_structures

*&---------------------------------------------------------------------*
*&
Form convert_0001
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form convert_0001. " MAT_REC
check g_skip_transaction = no.
g_skip_record = no.
g_record = 'MAT_REC'.
* --- __BEGIN_OF_RECORD__
MAT_REC = INIT_MAT_REC.
* --- MAT_REC-TABNAME
MAT_REC-TABNAME = 'MAT_REC'.
* --- MAT_REC-TCODE
MAT_REC-TCODE = 'MM02'.
* --- MAT_REC-MATNR
MAT_REC-MATNR = MAT_CH-MATNR.
* --- MAT_REC-WERKS
MAT_REC-WERKS = MAT_CH-WERKS.
* --- MAT_REC-DISMM
MAT_REC-DISMM = MAT_CH-DISMM.

* --- MAT_REC-DISPO
MAT_REC-DISPO = MAT_CH-DISPO.
* --- MAT_REC-DISLS
MAT_REC-DISLS = MAT_CH-DISLS.
* --- MAT_REC-BESKZ
MAT_REC-BESKZ = MAT_CH-BESKZ.
* --- MAT_REC-FHORI
MAT_REC-FHORI = MAT_CH-FHORI.
* --- __END_OF_RECORD__
transfer_record.
g_skip_record = no.
endform.

"convert_0001