02-16-2007 11:16 AM
hi ,
whatever data i am sending through idoc from outbound to inbound,how can i upload that data into excel sheet.
with regard,
rohit
02-16-2007 11:47 AM
Hi rohit,
this function is not provided by SAP, you have to create your own small program: The IDOC table (probably EDID4) are combined of administrative information and a data part. From this you can resolve the multidimensional structure of the IDOC: The data part must be assigned to the respective structure to extract the field data.
Do you have an idea how the IDOC data should be presentet in Excel cells?
Regards,
Clemens
02-16-2007 11:20 AM
There is no function that I know of to be able to load an IDoc into a spreadsheet.
02-16-2007 11:24 AM
wil following Fms help -
/GAMMA/GV_IDOC
/GAMMA/WRITE_IDOC_21
/GAMMA/WRITE_IDOC_40
BBP_CUF_READ_IDOC_DATA
may be if yes then u can read idoc data from then and then use GUI_DOWNLOAD FM to download this data into a Excel.
02-16-2007 11:47 AM
Hi Rohit,
The IDOC data are stored in tables such as :
EDID4 - IDOC Data Records
EDIDC - IDOC Control Records
EDIDS - IDOC Status Records
you can use this table to download the data into excel file.
Regards,
A.Fahrudeen
02-16-2007 11:47 AM
Hi rohit,
this function is not provided by SAP, you have to create your own small program: The IDOC table (probably EDID4) are combined of administrative information and a data part. From this you can resolve the multidimensional structure of the IDOC: The data part must be assigned to the respective structure to extract the field data.
Do you have an idea how the IDOC data should be presentet in Excel cells?
Regards,
Clemens
02-16-2007 1:04 PM
&----
*& Report ZIDOC_DOWNLOAD_TO_EXCEL
&----
REPORT zidoc_download_to_excel.
TYPE-POOLS : abap.
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat.
DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
TYPES: BEGIN OF ty_idoc_data,
segnam TYPE edi_segnam,
sdata TYPE edi_sdata,
END OF ty_idoc_data.
TYPES: BEGIN OF ty_file,
segnam TYPE edi_segnam,
field TYPE fieldname,
value(255),
END OF ty_file.
TYPES: BEGIN OF ty_fields,
segnam TYPE tabname,
field TYPE fieldname,
POSITION type TABFDPOS,
END OF ty_fields.
TYPES: BEGIN OF ty_fieldnames,
field TYPE fieldname,
END OF ty_fieldnames.
DATA: t_idoc_data TYPE STANDARD TABLE OF ty_idoc_data,
t_file TYPE STANDARD TABLE OF ty_file,
t_fields TYPE STANDARD TABLE OF ty_fields,
t_fieldnames TYPE STANDARD TABLE OF ty_fieldnames.
DATA: st_idoc_data TYPE ty_idoc_data,
st_file TYPE ty_file,
st_fields TYPE ty_fields,
st_fieldnames TYPE ty_fieldnames.
data: w_count type sytabix,
w_filename type string value 'C:\IDoc.xls'.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<file_table> TYPE STANDARD TABLE,
<segment>,
<field>,
<dyn_field>,
<file_field>,
<table_field>.
PARAMETER: p_docnum TYPE edi_docnum.
START-OF-SELECTION.
PERFORM f_read_idoc_data.
PERFORM f_read_segment_structures.
PERFORM f_set_up_output_file_data.
perform f_download_to_excel.
END-OF-SELECTION.
&----
*& Form f_read_idoc_data
&----
Read the IDoc data
----
FORM f_read_idoc_data .
SELECT segnam
sdata
INTO TABLE t_idoc_data
FROM edid4
WHERE docnum EQ p_docnum.
IF sy-subrc NE 0.
MESSAGE s000(38) WITH 'No IDoc data found'.
ENDIF.
ENDFORM. " f_read_idoc_data
&----
*& Form f_set_up_output_file_data
&----
Set up the file data
----
FORM f_set_up_output_file_data .
LOOP AT t_idoc_data INTO st_idoc_data.
clear w_count.
PERFORM f_set_up_segment_structure.
<segment> = st_idoc_data-sdata.
st_file-segnam = st_idoc_data-segnam.
LOOP AT t_fields INTO st_fields WHERE segnam EQ st_idoc_data-segnam.
add 1 to w_count.
ASSIGN COMPONENT w_count OF STRUCTURE <segment> TO <field>.
st_file-field = st_fields-field.
st_file-value = <field>.
APPEND st_file TO t_file.
ENDLOOP.
ENDLOOP.
ENDFORM. " f_set_up_output_file_data
&----
*& Form f_read_segment_structures
&----
Get a list of fields in each segment
----
FORM f_read_segment_structures .
SELECT tabname
fieldname
POSITION
INTO TABLE t_fields
FROM dd03l
FOR ALL ENTRIES IN t_idoc_data
WHERE tabname EQ t_idoc_data-segnam.
sort t_fields by segnam position.
ENDFORM. " f_rEAD_SEGMENT_STRUCTURES
&----
*& Form f_set_up_segment_structure
&----
FORM f_set_up_segment_structure .
REFRESH ifc.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( st_idoc_data-segnam ).
idetails[] = ref_table_des->components[].
LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <file_table>.
Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <file_table>.
ASSIGN dy_line->* TO <segment>.
ENDFORM. " f_set_up_segment_structure
&----
*& Form f_download_to_excel
&----
form f_download_to_excel .
st_fieldnames = 'SEGMENT NAME'. append st_fieldnames to t_fieldnames.
st_fieldnames = 'FIELD'. append st_fieldnames to t_fieldnames.
st_fieldnames = 'DATA'. append st_fieldnames to t_fieldnames.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'DAT'
filename = w_filename
write_field_separator = 'X'
TABLES
fieldnames = t_fieldnames
data_tab = t_file
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
message s000(38) with 'File'
w_filename
'created'.
endform. " f_download_to_excel
Message was edited by:
Martin Shinks
02-16-2007 5:13 PM
02-16-2007 1:46 PM
Hi rohit,
in the Posting program of that particular idoc write your code and dowload to excel sheet
Prashanth
02-16-2007 5:15 PM