Data Uploader Program
Data Uploader Program
end of ty_snwd_bp,
begin of ty_snwd_pd,
client type string, node_key type string, product_id type string, type_code
type string,
category type string, created_by type string, created_at type string,
changed_by type string,
changed_at type string, name_guid type string, desc_guid type string,
supplier_guid type string, tax_tarif_code type string, measure_unit type
string,
weight_measure type string, weight_unit type string, currency_code type
string,
price type string, product_pic_url type string, width type string, depth
type string,
height type string, dim_unit type string, dummy_field_pd type string,
end of ty_snwd_pd,
begin of ty_snwd_texts,
client type string, node_key type string, parent_key type string, language
type string, text type string, _dataaging type string,
end of ty_snwd_texts,
begin of ty_snwd_so,
client type string, node_key type string, so_id type string, created_by type
string, created_at type string, changed_by type string,
changed_at type string, created_by_bp type string, changed_by_bp type string,
note_guid type string, buyer_guid type string,
currency_code type string, gross_amount type string, net_amount type string,
tax_amount type string, lifecycle_status type string,
billing_status type string, delivery_status type string, op_id type string,
_dataaging type string, dummy type string,
overall_status type string, buy_contact_guid type string, ship_to_adr_guid
type string, bill_to_adr_guid type string, payment_method type string,
payment_terms type string,
end of ty_snwd_so,
begin of ty_snwd_so_inv_head,
client type string, node_key type string, so_guid type string, dly_note_number
type string, created_by type string, created_at type string,
changed_by type string, changed_at type string, gross_amount type string,
net_amount type string, tax_amount type string,
currency_code type string, buyer_guid type string, dunning_level type string,
payment_status type string,
_dataaging type string,
end of ty_snwd_so_inv_head,
begin of ty_snwd_so_inv_item,
client type string, node_key type string, parent_key type string, so_item_guid
type string,
quantity type string, quantity_unit type string, gross_amount type string,
net_amount type string, tax_amount type string, currency_code type string,
product_guid type string, inv_item_pos type string, _dataaging type string,
end of ty_snwd_so_inv_item.
if gv_prod = 'X'.
delete from snwd_pd.
delete from snwd_texts.
data: lt_prd type table of snwd_pd,
ls_prd type snwd_pd.
lo_uploader->max_rows = 125.
lo_uploader->filename = 'C:\epmdata\snwd_pd.xls'.
lo_uploader->header_rows_count = 2.
lo_uploader->upload( changing ct_data = t_snwd_pd ).
* delete from edids.
loop at t_snwd_pd assigning field-symbol(<str>).
assign component 'CLIENT' of structure <str> to <fs>.
<fs> = sy-mandt.
get time stamp field lv_times.
<str>-changed_at = lv_times.
<str>-created_at = lv_times.
move-corresponding <str> to ls_prd.
append ls_prd to lt_prd.
endloop.
lo_uploader->max_rows = 125.
lo_uploader->filename = 'C:\epmdata\SNWD_TEXTS.xls'.
lo_uploader->header_rows_count = 2.
lo_uploader->upload( changing ct_data = t_snwd_texts ).
* delete from edids.
loop at t_snwd_texts assigning field-symbol(<strt>).
assign component 'MANDT' of structure <strt> to <fs>.
<fs> = sy-mandt.
move-corresponding <strt> to ls_prdt.
append ls_prdt to lt_prdt.
endloop.
lo_uploader->max_rows = 95.
lo_uploader->filename = 'C:\epmdata\snwd_bpa.xls'.
lo_uploader->header_rows_count = 2.
lo_uploader->upload( changing ct_data = t_snwd_bpa ).
* delete from edids.
loop at t_snwd_bpa assigning field-symbol(<strb>).
assign component 'CLIENT' of structure <strb> to <fs>.
<fs> = sy-mandt.
get time stamp field lv_times.
<strb>-changed_at = lv_times.
<strb>-created_at = lv_times.
move-corresponding <strb> to ls_bp.
append ls_bp to lt_bp.
endloop.
if gv_inv = 'X'.
* delete from snwd_so_inv_head.
* delete from snwd_so_inv_item.
* data: lt_prdi type table of snwd_so_inv_head,
* ls_prdi type snwd_so_inv_head.
*
* lo_uploader->max_rows = 1000.
* lo_uploader->filename = 'C:\epmdata\SNWD_SO_INV_HEAD.xls'.
* lo_uploader->header_rows_count = 2.
* lo_uploader->upload( changing ct_data = t_snwd_so_inv ).
** delete from edids.
* loop at t_snwd_so_inv assigning field-symbol(<strin>).
* assign component 'CLIENT' of structure <strin> to <fs>.
* <fs> = sy-mandt.
* get time stamp field lv_times.
* <strin>-changed_at = lv_times.
* <strin>-created_at = lv_times.
* move-corresponding <strin> to ls_prdi.
* append ls_prdi to lt_prdi.
* endloop.
*
* modify snwd_so_inv_head from table lt_prdi.
lo_uploader->max_rows = 5880.
lo_uploader->filename = 'C:\epmdata\snwd_so_inv_item.xls'.
lo_uploader->header_rows_count = 2.
lo_uploader->upload( changing ct_data = t_snwd_so_inv_itm ).
* delete from edids.
loop at t_snwd_so_inv_itm assigning field-symbol(<stritm>).
assign component 'CLIENT' of structure <stritm> to <fs>.
<fs> = sy-mandt.
move-corresponding <stritm> to ls_prditm.
append ls_prditm to lt_prditm.
endloop.
endif.
IF gvinvpr = 'X'.
data: BEGIN OF lt_products occurs 0,
fromp type snwd_so-node_key,
top type snwd_so-node_key,
END OF lt_products,
ls_products like LINE OF lt_products.
<orders>-product_guid = ls_prodc-node_key.
ENDLOOP.
ENDIF.
if gvinvbp = 'X'.
SELECT * FROM snwd_bpa INTO TABLE @data(lt_ord) WHERE bp_role = '1' or bp_role
= '01'.
<order>-buyer_guid = ls_prod-node_key.
ENDLOOP.
endif.
if gv_adr = 'X'.
**Adjust Address and BPA table GUIDS
data: itabx type table of snwd_ad.
select * from snwd_ad into table @data(itab) order by city.
if gv_dat = 'X'.
** set some date in invoice header as old
data : lv_date type datum,
lv_val type snwd_so_inv_head-created_at.
endif.
*
form get_random_date.
data:
o_rand type ref to cl_abap_random_int,
n type i,
seed type i.
seed = cl_abap_random=>seed( ).
cl_abap_random_int=>create(
exporting
seed = seed
min = 0
max = 100
receiving
prng = o_rand
).
n = o_rand->get_next( ).
endform.
method do_upload.
endmethod. "do_upload
endclass. "lcl_excel_uploader IMPLEMENTATION
*