‎2008 Apr 10 2:44 PM
Hi all,
I need to upload datas from 4 different excel file and covert them into a single file. Is there any sample file for this kind of program.
the problem here is the data structure for the output file is different.
data : Begin of itab_a occurs 0,
land(2) type c,
spwoc(6) type c,
Matnr(8) type c,
Quan(20) type c,
end of itab.
data: begin of itab1 occurs 0,
fesp(14),
fland(2), "
spwoc type spwoc,
ean(13),
labst(13), "
end of t_export.
any sample program for this
regards
Ab
‎2008 Apr 10 10:58 PM
Hiii,
I am providing you with the code which will fetch data from several tables and finally place them in one table.your requirement slightly matches with my program.you need to frtch from several flat files,using function modules.
Reward points if useful.This is not complex one try to follow this
report zvsar10748_returnorder.
&----
*& TYPE-POOLS
&----
type-pools : slis.
&----
*& Structures
&----
types : begin of ty_final,
auart type auart, "Sales Document Type
kunnr type kunag, "Sold-to party
vbeln type vbeln, "Sales Document
vdatu type edatu_vbak, "Requested delivery date
faksk type faksk, "Billing block in SD document
posnr type posnr_va, "Sales Document Item
matnr type matnr, "Material Number
prodh type prodh_d, "Product hierarchy
kwmeng type kwmeng, "Cumulative order quantity in sales units
vrkme type vrkme, "Sales Unit
ntgew type ntgew_ap, "Net Weight of the Item
gewei type gewei, "Weight Unit
prctr type prctr, "Profit Center
rfbsk type rfbsk, "Status for transfer to accounting
kschl type kscha, "Condition type
kwert type kwert, "Condition value
stprs type stprs, "Standard price
end of ty_final.
types : begin of ty_vbak,
auart type auart, "Sales Document Type
kunnr type kunag, "Sold-to party
vbeln type vbeln, "Sales Document
vdatu type edatu_vbak, "Requested delivery date
faksk type faksk, "Billing block in SD document
end of ty_vbak.
types : begin of ty_vbap,
vbeln type vbeln, "Sales Document
bwtar type bwtar_d, "Valuation type
posnr type posnr_va, "Sales Document Item
matnr type matnr, "Material Number
prodh type prodh_d, "Product hierarchy
kwmeng type kwmeng, "Cumulative order quantity
in sales units
vrkme type vrkme, "Sales Unit
ntgew type ntgew_ap, "Net Weight of the Item
gewei type gewei, "Weight Unit
prctr type prctr, "Profit Center
end of ty_vbap.
types : begin of ty_vbrk,
vbeln type vbeln, "Sales Document
rfbsk type rfbsk, "Status for transfer to accounting
knumv type knumv, "Number of the document condition
end of ty_vbrk.
types : begin of ty_konv,
knumv type knumv, "Number of the document condition
kschl type kscha, "Condition type
kwert type kwert, "Condition value
end of ty_konv.
types : begin of ty_mbew,
bwtar type bwtar_d, "Valuation type
matnr type matnr, "Material Number
stprs type stprs, "Standard price
end of ty_mbew.
&----
*& WorkAreas & Internal tables
&----
data : wa_final type ty_final,
it_final type table of ty_final. "Work Area & Internal table for final output
data : wa_vbak type ty_vbak,
it_vbak type table of ty_vbak. "Work Area & Internal table for VBAK
data : wa_vbap type ty_vbap,
it_vbap type table of ty_vbap. "Work Area & Internal table for VBAP
data : wa_vbrk type ty_vbrk,
it_vbrk type table of ty_vbrk. "Work Area & Internal table for VBRK
data : wa_konv type ty_konv,
it_konv type table of ty_konv. "Work Area & Internal table for KONV
data : wa_mbew type ty_mbew,
it_mbew type table of ty_mbew. "Work Area & Internal table for MBEW
data : v_auart type vbak-auart,
v_vdatu type vbak-vdatu.
data : v_tvak type tvak-auart.
data : wa_layout type slis_layout_alv. "Layout for the output
data : wa_fieldcat type slis_fieldcat_alv,
it_fieldcat type slis_t_fieldcat_alv. "Work Area & Internal table for fieldcatlog
&----
*& Definition of Selection Screen
&----
selection-screen : begin of block b1 with frame title text-001.
selection-screen : begin of line.
selection-screen comment 5(15) text-002.
selection-screen position 20.
select-options doctype for v_auart.
selection-screen : end of line.
selection-screen : begin of line.
selection-screen comment 5(15) text-003.
selection-screen position 20.
select-options date for v_vdatu.
selection-screen : end of line.
selection-screen : end of block b1.
&----
*& AT SELECTION SCREEN ON FIELD
&----
at selection-screen on doctype.
select single auart from tvak into v_tvak where auart in doctype.
if sy-subrc <> 0 .
message E000(0) with 'Enter Valid Document Type'.
endif.
&----
*& START OF SELECTION
&----
start-of-selection.
perform select_vbak_vbap.
perform select_vbrk.
perform select_konv.
perform select_mbew.
perform append_data_final.
perform write_output.
perform populate_layout.
perform populate_fieldcat.
perform write_output_alv.
&----
*& Form select_vbak_vbap
&----
form select_vbak_vbap .
select auart kunnr vbeln vdatu faksk
from vbak into table it_vbak
where auart in doctype
and vdatu in date.
select vbeln bwtar posnr matnr prodh kwmeng vrkme ntgew gewei prctr
from vbap into table it_vbap
for all entries in it_vbak
where vbeln = it_vbak-vbeln.
endform. " select_vbak_vbap
&----
*& Form select_vbrk
&----
form select_vbrk .
select vbeln rfbsk knumv
from vbrk into table it_vbrk
for all entries in it_vbak
where vbeln = it_vbak-vbeln.
endform. " select_vbrk
&----
*& Form select_konv
&----
form select_konv .
select knumv kschl kwert
from konv into table it_konv
for all entries in it_vbrk
where knumv = it_vbrk-knumv.
endform. " select_konv
&----
*& Form select_mbew
&----
form select_mbew .
select matnr
bwtar
stprs
from mbew into table it_mbew
for all entries in it_vbap
where matnr = it_vbap-matnr
and bwtar = it_vbap-bwtar.
endform. " select_mbew
&----
*& Form append_data_final
&----
form append_data_final .
loop at it_vbak into wa_vbak.
wa_final-auart = wa_vbak-auart.
wa_final-kunnr = wa_vbak-kunnr.
wa_final-vbeln = wa_vbak-vbeln.
wa_final-vdatu = wa_vbak-vdatu.
wa_final-faksk = wa_vbak-faksk.
read table it_vbap into wa_vbap with key vbeln = wa_vbak-vbeln.
wa_final-posnr = wa_vbap-posnr.
wa_final-matnr = wa_vbap-matnr.
wa_final-prodh = wa_vbap-prodh.
wa_final-kwmeng = wa_vbap-kwmeng.
wa_final-vrkme = wa_vbap-vrkme.
wa_final-ntgew = wa_vbap-ntgew.
wa_final-gewei = wa_vbap-gewei.
wa_final-prctr = wa_vbap-prctr.
read table it_vbrk into wa_vbrk with key vbeln = wa_vbak-vbeln.
wa_final-rfbsk = wa_vbrk-rfbsk.
read table it_konv into wa_konv with key knumv = wa_vbrk-knumv.
wa_final-kschl = wa_konv-kschl.
wa_final-kwert = wa_konv-kwert.
read table it_mbew into wa_mbew with key matnr = wa_vbap-matnr.
wa_final-stprs = wa_mbew-stprs.
append wa_final to it_final.
endloop.
endform. " append_data_final
&----
*& Form write_output
&----
form write_output .
loop at it_final into wa_final.
write : / wa_final-auart,
wa_final-kunnr,
wa_final-vbeln,
wa_final-vdatu,
wa_final-faksk,
wa_final-posnr,
wa_final-matnr,
wa_final-prodh,
wa_final-kwmeng,
wa_final-vrkme,
wa_final-ntgew,
wa_final-gewei,
wa_final-prctr,
wa_final-rfbsk,
wa_final-kschl,
wa_final-kwert,
wa_final-stprs.
endloop.
endform. " write_output
&----
*& Form write_output_alv
&----
form write_output_alv .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_interface_check = ' '
i_callback_program = ' '
i_grid_title = 'SALES RETURN ORDERS'
is_layout = wa_layout
it_fieldcat = it_fieldcat
tables
t_outtab = it_final.
endform. " write_output_alv
&----
*& Form populate_layout
&----
form populate_layout .
wa_layout-zebra = 'X'.
wa_layout-no_colhead = ' '.
endform. " populate_layout
&----
*& Form populate_fieldcat
&----
form populate_fieldcat .
wa_fieldcat-fieldname = 'AUART' .
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-ref_fieldname = 'AUART'.
wa_fieldcat-seltext_m = 'DocType'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'KUNNR' .
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-ref_fieldname = 'KUNNR'.
wa_fieldcat-seltext_m = 'Customer'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'VBELN' .
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-ref_fieldname = 'VBELN'.
wa_fieldcat-seltext_m = 'DocNumber'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'VDATU' .
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-ref_fieldname = 'VDATU'.
wa_fieldcat-seltext_m = 'Delivery'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'FAKSK' .
wa_fieldcat-tabname = 'IT_VBAK'.
wa_fieldcat-ref_fieldname = 'FAKSK'.
wa_fieldcat-seltext_m = 'BillBlock'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'POSNR' .
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-ref_fieldname = 'POSNR'.
wa_fieldcat-seltext_m = 'Item'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR' .
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-ref_fieldname = 'MATNR'.
wa_fieldcat-seltext_m = 'Material'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'PRODH' .
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-ref_fieldname = 'PRODH'.
wa_fieldcat-seltext_m = 'Heirarchy'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'KWMENG' .
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-ref_fieldname = 'KWMENG'.
wa_fieldcat-seltext_m = 'Order'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'VRKME' .
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-ref_fieldname = 'VRKME'.
wa_fieldcat-seltext_m = 'SalesUnit'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'NTGEW' .
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-ref_fieldname = 'NTGEW'.
wa_fieldcat-seltext_m = 'NetWeight'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'GEWEI' .
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-ref_fieldname = 'GEWEI'.
wa_fieldcat-seltext_m = 'Weight'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'PRCTR' .
wa_fieldcat-tabname = 'IT_VBAP'.
wa_fieldcat-ref_fieldname = 'PRCTR'.
wa_fieldcat-seltext_m = ''.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'RFBSK' .
wa_fieldcat-tabname = 'IT_VBRK'.
wa_fieldcat-ref_fieldname = 'RFBSK'.
wa_fieldcat-seltext_m = 'Status'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'KSCHL' .
wa_fieldcat-tabname = 'IT_KONV'.
wa_fieldcat-ref_fieldname = 'KSCHL'.
wa_fieldcat-seltext_m = 'ConditionType'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'KWERT' .
wa_fieldcat-tabname = 'IT_KONV'.
wa_fieldcat-ref_fieldname = 'KWERT'.
wa_fieldcat-seltext_m = 'ConditionVal'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'STPRS' .
wa_fieldcat-tabname = 'IT_MBEW'.
wa_fieldcat-ref_fieldname = 'STPRS'.
wa_fieldcat-seltext_m = 'StandardPrice'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
endform. " populate_fieldcat
Edited by: ravee on Apr 11, 2008 3:29 AM
‎2008 Apr 11 3:13 AM
Hi, We have solution for your requirement. But tell me somethings. 1. Are 4 tables have any relation among them ? 2. What are you going to do after clubbing 4 tables ? Regards, Venkat.O