You are on page 1of 4

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

* LSM Workbench: Data Conversion Program


* Program:
/1CADMC/SAP_LSMW_CONV_00000016
* Date:
02.09.2012
* Time:
22:18:43
* User:
NEERAJD
* Project:
MAT_DEL2
* Subproject: MAT_DEL2
* Object:
MAT_DEL2
************************************************************************
report /1CADMC/SAP_LSMW_CONV_00000016
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_DEL occurs 0,
TABNAME(000030) type C,
TCODE(000020) type C,
MATNR(000018) type C,
LVOMA(000001) type C,
end of MAT_DEL .
data:
init_MAT_DEL like MAT_DEL,
prev_MAT_DEL like MAT_DEL.
* Source structure definitions
data:
begin of LSMW_MAT_DEL2,
MATNR(018) type C,
LVOMA(001) type C,
end of LSMW_MAT_DEL2.
data:
begin of MAT_DEL2 occurs 0.
include structure LSMW_MAT_DEL2.
data: recnr_000001 type i.
data:
end of MAT_DEL2.
* Counters
data:
g_cnt_MAT_DEL2 type i.
* Counter ct_xxxxxxxxxx: number of transferred records
data:
ct_MAT_DEL type i,
cs_MAT_DEL 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_DEL2
g_subproj = 'MAT_DEL2
g_object = 'MAT_DEL2

'.
'.
'.

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_DEL2'.
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_DEL2.
move-corresponding <g_buffer_to_struc> to MAT_DEL2.
MAT_DEL2-recnr_000001 = g_cnt_records_read.
append MAT_DEL2.
add 1 to g_cnt_MAT_DEL2.
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_DEL2.
perform convert_0001. " MAT_DEL
ENDLOOP.
* End of transaction
transfer_transaction.
endform.

"convert_transaction

*&---------------------------------------------------------------------*
*&
Form clear_source_tables
*&---------------------------------------------------------------------*
*
text

*----------------------------------------------------------------------*
form clear_source_tables.
clear MAT_DEL2[].
endform.

"clear_source_tables

*&---------------------------------------------------------------------*
*&
Form create_initial_structures
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form create_initial_structures.
perform initialize_with_nodata using
'MAT_DEL' init_MAT_DEL.
endform.

"create_initial_structures

*&---------------------------------------------------------------------*
*&
Form convert_0001
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form convert_0001. " MAT_DEL
check g_skip_transaction = no.
g_skip_record = no.
g_record = 'MAT_DEL'.
* --- __BEGIN_OF_RECORD__
MAT_DEL = INIT_MAT_DEL.
* --- MAT_DEL-TABNAME
MAT_DEL-TABNAME = 'MAT_DEL'.
* --- MAT_DEL-TCODE
MAT_DEL-TCODE = 'MM06'.
* --- MAT_DEL-MATNR
MAT_DEL-MATNR = MAT_DEL2-MATNR.
* --- MAT_DEL-LVOMA
MAT_DEL-LVOMA = MAT_DEL2-LVOMA.
* --- __END_OF_RECORD__
transfer_record.
g_skip_record = no.
endform.

"convert_0001