You are on page 1of 6

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

* LSM Workbench: Data Conversion Program


* Program:
/1CADMC/SAP_LSMW_CONV_00000006
* Date:
03.06.2011
* Time:
13:07:24
* User:
VIJAY
* Project:
LSMW_SO_VA01
* Subproject: SOPROJ
* Object:
SOOBJ_REC
************************************************************************
report /1CADMC/SAP_LSMW_CONV_00000006
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 SOVA02_REC occurs 0,
TABNAME(000030) type C,
TCODE(000020) type C,
AUART(000004) type C,
VKORG(000004) type C,
VTWEG(000002) type C,
SPART(000002) type C,
BSTKD(000035) type C,
BSTDK(000010) type C,
KUNNR(000010) type C,
KETDAT(000010) type C,
KPRGBZ(000001) type C,
DWERK(000004) type C,
PRSDT(000010) type C,
MABNR_01(000018) type C,
KWMENG_01(000019) type C,
WERKS_01(000004) type C,
KBETR_01(000016) type C,
KOEIN_01(000005) type C,
ZTERM(000004) type C,
INCO1(000003) type C,
INCO2(000028) type C,
VBAP_SELKZ_01(000001) type C,
KSCHL_11(000004) type C,
KBETR_11(000016) type C,
end of SOVA02_REC .
data:
init_SOVA02_REC like SOVA02_REC,
prev_SOVA02_REC like SOVA02_REC.
* Source structure definitions
data:
begin of LSMW_VA01S_NEW,
ORDERTYPE(004) type C,
SALESORG(004) type C,
DISTCHAN(002) type C,
DIVISION(002) type C,

PONUMBER(025) type C,
PODATE(015) type C,
SOLDTOPARTY(015) type C,
REQDELDATE(015) type C,
DATETYPE(001) type C,
DELIVERPLANT(004) type C,
PRICINGDATE(015) type C,
MATERIALCODE(015) type C,
POQTY(010) type C,
MATPLANT(004) type C,
BASEPRICE(010) type C,
CURRENCY(003) type C,
PAYTERM(004) type C,
INCO1(003) type C,
INCO2(025) type C,
VBAP_SELKZ_01(001) type C,
FREIGHT(004) type C,
FREIGHTVALUE(010) type C,
end of LSMW_VA01S_NEW.
data:
begin of VA01S_NEW occurs 0.
include structure LSMW_VA01S_NEW.
data: recnr_000001 type i.
data:
end of VA01S_NEW.
* Counters
data:
g_cnt_VA01S_NEW type i.
* Counter ct_xxxxxxxxxx: number of transferred records
data:
ct_SOVA02_REC type i,
cs_SOVA02_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 = 'LSMW_SO_VA01 '.
g_subproj = 'SOPROJ
'.
g_object = 'SOOBJ_REC
'.
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 'VA01S_NEW'.
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_VA01S_NEW.
move-corresponding <g_buffer_to_struc> to VA01S_NEW.
VA01S_NEW-recnr_000001 = g_cnt_records_read.
append VA01S_NEW.
add 1 to g_cnt_VA01S_NEW.
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 VA01S_NEW.
perform convert_0001. " SOVA02_REC
ENDLOOP.
* End of transaction
transfer_transaction.
endform.

"convert_transaction

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

"clear_source_tables

*&---------------------------------------------------------------------*
*&
Form create_initial_structures
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form create_initial_structures.
perform initialize_with_nodata using
'SOVA02_REC' init_SOVA02_REC.
endform.

"create_initial_structures

*&---------------------------------------------------------------------*

*&
Form convert_0001
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
form convert_0001. " SOVA02_REC
check g_skip_transaction = no.
g_skip_record = no.
g_record = 'SOVA02_REC'.
* --- __BEGIN_OF_RECORD__
SOVA02_REC = INIT_SOVA02_REC.
* --- SOVA02_REC-TABNAME
SOVA02_REC-TABNAME = 'SOVA02_REC'.
* --- SOVA02_REC-TCODE
SOVA02_REC-TCODE = 'VA01'.
* --- SOVA02_REC-AUART
SOVA02_REC-AUART = VA01S_NEW-ORDERTYPE.
* --- SOVA02_REC-VKORG
SOVA02_REC-VKORG = VA01S_NEW-SALESORG.
* --- SOVA02_REC-VTWEG
SOVA02_REC-VTWEG = VA01S_NEW-DISTCHAN.
* --- SOVA02_REC-SPART
SOVA02_REC-SPART = VA01S_NEW-DIVISION.
* --- SOVA02_REC-BSTKD
SOVA02_REC-BSTKD = VA01S_NEW-PODATE.
* --- SOVA02_REC-BSTDK
SOVA02_REC-BSTDK = VA01S_NEW-PODATE.
* Caution: Source field is longer than target field
* --- SOVA02_REC-KUNNR
SOVA02_REC-KUNNR = VA01S_NEW-SOLDTOPARTY.
* Caution: Source field is longer than target field
* --- SOVA02_REC-KETDAT
SOVA02_REC-KETDAT = VA01S_NEW-REQDELDATE.
* Caution: Source field is longer than target field
* --- SOVA02_REC-KPRGBZ
SOVA02_REC-KPRGBZ = VA01S_NEW-DATETYPE.
* --- SOVA02_REC-DWERK
SOVA02_REC-DWERK = VA01S_NEW-DELIVERPLANT.
* --- SOVA02_REC-PRSDT
SOVA02_REC-PRSDT = VA01S_NEW-PRICINGDATE.
* Caution: Source field is longer than target field
* --- SOVA02_REC-MABNR_01
SOVA02_REC-MABNR_01 = VA01S_NEW-MATERIALCODE.

* --- SOVA02_REC-KWMENG_01
SOVA02_REC-KWMENG_01 = VA01S_NEW-POQTY.
* --- SOVA02_REC-WERKS_01
SOVA02_REC-WERKS_01 = VA01S_NEW-MATPLANT.
* --- SOVA02_REC-KBETR_01
SOVA02_REC-KBETR_01 = VA01S_NEW-BASEPRICE.
* --- SOVA02_REC-KOEIN_01
SOVA02_REC-KOEIN_01 = VA01S_NEW-CURRENCY.
* --- SOVA02_REC-ZTERM
SOVA02_REC-ZTERM = VA01S_NEW-PAYTERM.
* --- SOVA02_REC-INCO1
SOVA02_REC-INCO1 = VA01S_NEW-INCO1.
* --- SOVA02_REC-INCO2
SOVA02_REC-INCO2 = VA01S_NEW-INCO2.
* --- SOVA02_REC-VBAP_SELKZ_01
SOVA02_REC-VBAP_SELKZ_01 = VA01S_NEW-VBAP_SELKZ_01.
* --- SOVA02_REC-KSCHL_11
SOVA02_REC-KSCHL_11 = VA01S_NEW-FREIGHT.
* --- SOVA02_REC-KBETR_11
SOVA02_REC-KBETR_11 = VA01S_NEW-FREIGHTVALUE.
* --- __END_OF_RECORD__
transfer_record.
g_skip_record = no.
endform.

"convert_0001