Logic issues for manipulation of internal table data
Hi,
I am having a issue with logic of one program.
In the <b>XVBAP</b> internal table of <b>SO</b> User Exit.
We will have fields like
<b>UPDKZ, POSNR, UEPOS, ZZECD[Z-Field] etc.</b>
Above fields are related to logic.
1. Now my first point is:
<b>We need to capture Records where UPDKZ='D' and ZZECD[Z-Field] is populated.</b>
For this we will write code as below:
<b>LOOP AT XVBAP WHERE UPDKZ EQ C_D AND
ZZECD NE SPACE.
Here we will store all fields in I_XVBAP I.Table
ENDLOOP.</b>
Supoose we have retrieved records as below:
<b>VBELN, UPDKZ, POSNR, UEPOS, ZZECD
100 D 000040 000030 Text1
100 D 000050 000020 Text2
100 D 000060 000000 Text3</b>
2. My second point here is:
<b>For Every Item[POSNR] we need to get the Higher level item from UEPOS field, If the Higher level Item also has UPDKZ = D, then move the base unit and all its components into an internal table. continue this process till UEPOS for POSNR is 000000 but High item should have UPDKZ = 'D', not only this all items in this chain should have UPDKZ = 'D'.</b>
Ex:
<b>Suppose for item 000050 UEPOS is 000020 then goto XVBAP with POSNR = UEPOS[000020] and UPDKZ = 'D' if yes and then pick up UEPOS for 000020 item and continue this process till UEPOS becomes 000000 and UPDKZ = 'D'.
Here from Low level to High level all the chain items should have UPDKZ = 'D'. Then only write all items into Final Internal table.</b>
<b>Need to do this process for all above rec's [40,50,60 - POSNR].</b>
Can anybody provide me the logic for the above scenario.
Thanks in advance.
Thanks and Regards,
Deep
Hi Anurag,
Your assumption is wrong.
See first when we get into our logic we will get <b>XVBAP</b> data as below:
<b>VBELN, POSNR, UEPOS, UPDKZ, ZZECD
100, 10, 00, D, Text1
100, 20, 00, , Text2
100, 30, 20, D, Text3
100, 40, 30, D, Text4
100, 50, 00, , Text5
100, 60, 00, D, Text6
100, 70, 60, D, Text7</b>
After we run first point we will get data as:
Here logic is pick up data where <b>UPDKZ = D</b> and <b>ZZECD NE SPACE</b>.
<b>VBELN, POSNR, UEPOS, UPDKZ, ZZECD
100, 10, 00, D, Text1
100, 30, 20, D, Text3
100, 40, 30, D, Text4
100, 60, 00, D, Text6
100, 70, 60, D, Text7</b>
Then we will goto second point:
Here we need to look into <b>3</b> things totally in 2nd point:
1. In loop Select the record which has <b>UEPOS EQ space</b>, <b>UPDKZ = D</b> and <b>POSNR</b> should not be <b>UEPOS</b> for any other record from above data from 1st point.
<b>100, 10, 00, D, Text1</b>
will be selected into final internal table as per this point.
2. If for a POSNR value UEPOS NE SPACE, UPDKZ = D then goto UEPOS's POSNR in high level check there if UPDKZ = D and then wether UEPOS is ZERO (or) contains any value.
If any value is there repeat the process till UEPOS become ZERO. Then for that final higher level item check UPDKZ value if it has value as 'D', If has then write all those records from low item to high item into final internal table.
<b>100, 60, 00, D, Text6
100, 70, 60, D, Text7</b>
In above for Item 70[POSNR] we have UEPOS as 60 and UPDKZ as D. then we will goto UEPOS's POSNR, Now POSNR is 60 then check it's UEPOS it is ZERO so check UPDKZ because it is D write both items 60, 70 into final internal table.
2. If for a POSNR value UEPOS NE SPACE, UPDKZ = D then goto UEPOS's POSNR in high level check there if UPDKZ = D and then wether UEPOS is ZERO (or) contains any value.
If any value is there repeat the process till UEPOS become ZERO. Then for that final higher level item check UPDKZ value if it has value as 'D', If it does not have UPDKZ as 'D' then don't write any item from low to high into final internal table.
If we take the scenario of below rows:
<b>100, 20, 00, , Text2
100, 30, 20, D, Text3
100, 40, 30, D, Text4</b>
POSNR-40 has UEPOS-30 & UPDKZ = D then UEPOS's POSNR-30 has UEPOS-20 and UPDKZ-D then UEPOS POSNR-20 has UEPOS as 00 then stop here and see UPDKZ which is ZERO so don't consider items 20,30,40 into final i.table.
In the above chain in any record UPDKZ is not 'D' then skip the process anddon't write the records into final internal table.
Final output will come as:
<b>100, 10, 00, D, Text1</b>
<b>100, 60, 00, D, Text6
100, 70, 60, D, Text7</b>
Thanks for all your efforts.
Thanks,
Deep
Similar Messages
-
Issue In internal table data population in the o/p
Dear Guru , I have encountered an issue for which i am not able to findout the logic . I have an internal table through which i am populating the below data for detail report format :->
Plant Material Number Storage Loc Movement Type Avg Days
019 0820B0073 MOD3 101 space
019 0820B0073 MOD3 101 space
019 0820B0073 MOD3 101 space
019 0820B0073 MOD3 101 space
019 0820B0073 MOD3 101 space
020 0820B0074 MOD4 101 space
020 0820B0074 MOD4 101 2
020 0820B0074 MOD4 101 3
The requirment is like this the summary report should show o/p like below addition of all the rows with respect to plant , material, storage location and movement type :-
Plant Material Number Storage Loc Movement Type Avg Days
019 0820B0073 MOD3 101 space
020 0820B0074 MOD4 101 5
but when i am adding it with respect to plant, material, storage location and movement type the o/p i am getting is like below
Plant Material Number Storage Loc Movement Type Avg Days
019 0820B0073 MOD3 101 0
020 0820B0074 MOD4 101 5
becasue addition of 5 spaces ( Avg Days )of plant 019 is coming as ZERO --> 0
so Guru what logic i should use to get the proper o/p,..I have Used Following logic to perform summation with respect to plant, material , storage loc and movement type.
CLEAR: wa_mkpf_mseg, w_werks, w_matnr, w_lgort, w_bwart.
LOOP AT t_mkpf_mseg INTO wa_mkpf_mseg.
IF wa_mkpf_mseg-werks EQ w_werks AND wa_mkpf_mseg-matnr EQ w_matnr AND wa_mkpf_mseg-lgort EQ w_lgort AND wa_mkpf_mseg-bwart EQ w_bwart.
CLEAR: wa_p_coi.
READ TABLE t_p_coi INTO wa_p_coi WITH KEY werks = wa_mkpf_mseg-werks matnr = wa_mkpf_mseg-matnr lgort = wa_mkpf_mseg-lgort bwart = wa_mkpf_mseg-bwart.
IF sy-subrc = 0.
wa_p_coi-Avg Days = wa_p_coi-Avg Days + wa_mkpf_mseg-Avg Days.
MODIFY t_p_coi FROM wa_p_coi TRANSPORTING Avg Days .
CLEAR: wa_p_coi, wa_p_coi.
endif.
ELSE.
wa_p_coi-werks = wa_mkpf_mseg-werks.
wa_p_coi-matnr = wa_mkpf_mseg-matnr.
wa_p_coi-bwart = wa_mkpf_mseg-bwart.
wa_p_coi-lgort = wa_mkpf_mseg-lgort.
wa_p_coi-Avg Days = wa_mkpf_mseg-Avg Days .
APPEND wa_p_coi TO t_p_coi.
CLEAR: wa_p_coi.
ENDIF.
w_werks = wa_mkpf_mseg-werks.
w_matnr = wa_mkpf_mseg-matnr.
w_lgort = wa_mkpf_mseg-lgort.
w_bwart = wa_mkpf_mseg-bwart.
CLEAR: wa_mkpf_mseg.
ENDLOOP.The soln what i found after working out
CLEAR: wa_mkpf_mseg, w_werks, w_matnr, w_lgort, w_bwart.
LOOP AT t_mkpf_mseg INTO wa_mkpf_mseg.
IF wa_mkpf_mseg-werks EQ w_werks AND wa_mkpf_mseg-matnr EQ w_matnr AND wa_mkpf_mseg-lgort EQ w_lgort AND wa_mkpf_mseg-bwart EQ w_bwart.
CLEAR: wa_p_coi.
READ TABLE t_p_coi INTO wa_p_coi WITH KEY werks = wa_mkpf_mseg-werks matnr = wa_mkpf_mseg-matnr lgort = wa_mkpf_mseg-lgort bwart = wa_mkpf_mseg-bwart.
IF sy-subrc = 0.
if wa_p_coi-Avg Days = ' ' and wa_mkpf_mseg-Avg Days = ' '.
wa_p_coi-Avg Days = ' '.
ELSE
wa_p_coi-Avg Days = wa_p_coi-Avg Days + wa_mkpf_mseg-Avg Days.
Endif.
MODIFY t_p_coi FROM wa_p_coi TRANSPORTING Avg Days .
CLEAR: wa_p_coi, wa_p_coi.
endif.
ELSE.
wa_p_coi-werks = wa_mkpf_mseg-werks.
wa_p_coi-matnr = wa_mkpf_mseg-matnr.
wa_p_coi-bwart = wa_mkpf_mseg-bwart.
wa_p_coi-lgort = wa_mkpf_mseg-lgort.
wa_p_coi-Avg Days = wa_mkpf_mseg-Avg Days .
APPEND wa_p_coi TO t_p_coi.
CLEAR: wa_p_coi.
ENDIF.
w_werks = wa_mkpf_mseg-werks.
w_matnr = wa_mkpf_mseg-matnr.
w_lgort = wa_mkpf_mseg-lgort.
w_bwart = wa_mkpf_mseg-bwart.
CLEAR: wa_mkpf_mseg.
ENDLOOP. -
i have a internal table i_final in program 1 and this internal table data need to be input of other program, so how i need to pass the i_final data to other program.
this is the code in program 1:
ENDIF.
**appending work area to internal table.
APPEND wa_final TO i_final.
ENDLOOP.
EXPORT i_final to memory id 'zfinal'.
this is the code in program 2:
TYPES: BEGIN OF t_final,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
blart TYPE bkpf-blart,
xblnr TYPE bkpf-xblnr,
ebeln TYPE ekbe-ebeln,
ebelp TYPE ekbe-ebelp,
belnr1 TYPE ekbe-belnr,
xblnr1 TYPE ekbe-xblnr,
ebeln1 TYPE ekko-ebeln,
exnum TYPE ekko-exnum,
lands TYPE ekko-lands,
stceg_l TYPE ekko-stceg_l,
END OF t_final.
DATA: i_final TYPE STANDARD TABLE OF t_final WITH HEADER LINE.
DATA: wa_final TYPE t_final.
IMPORT i_final from memory ID 'zfinal'.
write: i_final.
its giving Dump. -
Internal table data 1E2 automatically convert to scientific format
Dear all,
I have been searched for solution moths from the forums and tried all possible methods, but still no way to solve my above problem. I found a way to solve it partially for us, but may be very helpful for others who meet similly case like mine, so I posted here.
my problem is when I export my internal table data to Excel, the Cell data with 1E2 auto becomes 1.00E02, and 1E8 becomes 1.00E08, we need it to be 1E2 and 1E8 in excel.
you can recreate my problem by
1, input 1E2 into your Microsoft Excel, then Enter, it will auto change into scientific format. which is we do not want.
2, use any of your SAP system open any table as long as there is a Char (>3) field in that table. add some
data entry in that field in the form "any amount (<15) of numeric 1 to 9"E"any one or two numeric 1 to 9". such as, 123E2, 1234E12 etc. then save this table's data to local file spread sheet, or use any FM to download it to a Excel file, when you open this
file by Excel, the cell with above form will display as scientific. but
if you put three or more numeric after the "E", such as 123E123 it will
display correctly.
what I have done:
I searched in SCN for similar thread:
Export to Excel 2007 - item number problem
Exceding the limit of numbers in Excel at target side
Excel download cell format problem
Formating as Text in excel through SAP
Converting of amount field into excel file through GUI DOWNLOAD
Data downloaded to excel gets converted to exponential format.
Problem with Excel download and scientific number
Re: Issue in displaying numbers in Excel?
CSV Flat File Data Problem (Number converting to Scientific Notation)
Tested accordingly, But none of these works in our case. because our
ultimate receiver of email attachment will be external third party, we cannot ask
them to change anything in their Excel.
Search Microsoft help about Excel, http://support.microsoft.com/kb/214233,
and it says this "Automatic Number Formatting" is a normal behaviour of excel.
no way to turn it off, the "work-around" way that Microsoft provides is not suitable for our
case.
We test CL_iXML recently arrording to weblog http://wiki.sdn.sap.com/wiki/display/Snippets/FormattedExcelasEmailAttachment
it successful controled the format. so this could be a solution for others whose internal table size is small. but our 2MB internal table bocome 6MB when converted to xml file attachment, which cannot be received by our end user's mail box. too big.
So please advise your ideas.
Many thanks in advance!
Peter Ding
Thank you very much for your time!Hi,
You can achieve this by describing the spreadsheet in XML with the help of the DOM classes.
The later releases of Excel can read and save spreadsheets as XML, providing your release supports this you can achieve it.
Check out the following Wiki
[Excel - XML|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/exporting%2bdata%2bto%2bexcel%2b-%2bxml%2bto%2bthe%2brescue]
Regards,
Darren -
PDF File from an internal table data
I have an internal table ready for grid display of a report. But according to the new requirement, it shouldn't create a Spool request as it is affecting the performance of the system (because its a huge file with 3000+ pages).
So, now we want to create a (non-editable) PDF File and store it in an application server.
From the forum, i see that i have only one option, which is to Convert internal table data to OTF Format and then to PDF.
Right now i am using PRINT_TEXT to convert to OTF file and FM CONVERT_OTF for PDF file.
The challenges i am facing right now is..
1. After getting the OTF file from PRINT_TEXT, i couldn't get the correct PDF File. It shows random characters instead..
2. My internal table has 103 columns. So how should i accommodate data from all these columns into a single row on a PDF?
3. I couldn't create a table kind of view/display in PDF
Please help/advice me on the above issue.
Thanks,
SaradaHi,
103 columns need to be seen in at least 7 pages or more. Cant display in just 1 page.
I guess that better to create a smartforms and pass all the information from the table to the smartforms.
There you can create multipages.
Probably, that huge table need to separete it in 7 tables, so each page will get the information from one table...
i will try to do sth like that.
Regards
Miguel -
No storage space available for extending an internal table.
Hi All,
I am using Function Module : VC_I_GET_CONFIGURATION in FI related Sales Order Report to get
configuration data for fields Model/Engine and Line no.
when the program executed in Production environment, It is giving Runtime Error TSV_TNEW_PAGE_ALLOC_FAILED.
ShrtText : No storage space available for extending an internal table.
The termination occurred in the ABAP program "SAPLIBINF" in "SELECT_INSTANCES_01" . its all happening
in the above FM.
Is there any possibility to get configuration data (Model/Engine and Line no) with out using FM.
please advise me on how you would like to proceed related to this issue.
Thanks & Regards
Satish ReddyHi Satish,
Please go through the below links and see if you can use this to address your issue,
http://wiki.sdn.sap.com/wiki/display/ABAP/ReplacementofVC_I_GET_CONFIGURATIONforperfomance+tunning
VC_I_GET_CONFIGURATION and paging memory
Regards,
Chen
Edited by: Chen K V on May 26, 2011 2:34 PM -
Hi All,
I was created program to generate Dynamic field catalog and internal table, here is confusion how to display below mentioned internal table data to final dynamic internal table based on document type headings
This is Statsic internal table Data
1 0000123 GBP DA S 6265.45
2 0000123 GBP DA H 240.51
3 0000123 GBP DA S 35.82
4 0000123 GBP D1 H 281.85
5 0000123 GBP D1 S 23.41
6 0000123 GBP D1 S 34.23
7 0000123 GBP RV H 97.02
8 0000123 GBP RV S 52.90
9 0000123 GBP RV S 148.31
Can anybody suggest me how to populate the amount based on Document type and posting (credit or debit)
For Example
CUST DAC DAD D1C D1D RVC RVD
123 6265.45 240.51
35.82
Thanks in Advance
Sekhar
Moderator message: please do not open multiple threads for the same or similar issue.
Edited by: Thomas Zloch on Dec 9, 2011 4:17 PMHi All,
I was created program to generate Dynamic field catalog and internal table, here is confusion how to display below mentioned internal table data to final dynamic internal table based on document type headings
This is Statsic internal table Data
1 0000123 GBP DA S 6265.45
2 0000123 GBP DA H 240.51
3 0000123 GBP DA S 35.82
4 0000123 GBP D1 H 281.85
5 0000123 GBP D1 S 23.41
6 0000123 GBP D1 S 34.23
7 0000123 GBP RV H 97.02
8 0000123 GBP RV S 52.90
9 0000123 GBP RV S 148.31
Can anybody suggest me how to populate the amount based on Document type and posting (credit or debit)
For Example
CUST DAC DAD D1C D1D RVC RVD
123 6265.45 240.51
35.82
Thanks in Advance
Sekhar
Moderator message: please do not open multiple threads for the same or similar issue.
Edited by: Thomas Zloch on Dec 9, 2011 4:17 PM -
Dump -- No more storage space available for extending an internal table
In Our system we are getting this dump
No more storage space available for extending an internal table
and because of it no user is able to login into the system.
We have Some classes in the system and we have defined shared memories to all classes according to regions.
So for a particular class means users of a region are not able to logon to systems and we are getting these dumps in the system.
So please suggest first how to clear the shared memory & how to conclude what activity in system made the shared memory full.
Regards,
Shivam MittalMy OS is HP-UNIX..
And we do not access on OS level,So please suggest the way to clear it from SAP level.
In dump it is also mentioned:
The internal table "\AREA=<Name>\INSTANCE=$DEFAULT_INSTANCE$\VER
SID=2\OBJ={O:1.2*\CLASS=<CLASS>\DATA=GT_BUFFER[1]-DATA" could
not be further extended. To enable
error handling, the table had to be delete before this log was written.
As a result, the table is displayed further down or, if you branch to
the ABAP Debugger, with 0 rows.
At the time of the termination, the following data was determined for
the relevant internal table:
Memory location: "\AREA=<Name>\INST=$DEFAULT_INSTANCE$\CLNT=100"
Row width: 156
Number of rows: 0
Allocated rows: 63
Newly requested rows: 1216 (in 19 blocks)
Please also suggest what is the internel table name that is causing the issue.
Regards,
Shivam Mittal -
How to download internal table data into xml file?
Hi,
Experts,
I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
Thank you,
Shabeer ahmed.check this
data : gd_repid type sy-repid.
GD_REPID = SY-REPID.
DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
data : l_element type ref to if_ixml_element,
xml_ns_prefix_sf type string,
xml_ns_uri_sf type string.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'REPAIRDATA'
DATAOBJECT = IT_FINAL_LAST1[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
*Start of code for Header
* namespace
t_mnr = sy-datum+4(2).
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
LANGU = 'E'
MONTH = t_mnr
IMPORTING
T247 = wa_t247
concatenate sy-datum+6(2)
wa_t247-ktx
sy-datum(4) into t_var1.
concatenate sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2) into t_var2.
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
l_element = m_document->get_root_element( ).
xml_ns_prefix_sf = 'TIMESTAMP'.
concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
clear : t_var1,
t_var2,
t_mnr,
wa_t247.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'FILECREATOR'.
xml_ns_uri_sf = 'SAP'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMGROUP'.
xml_ns_uri_sf = '1'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMTYPES'.
xml_ns_uri_sf = 'W'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
*End of Code for Header
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
*Start of Code for File name
concatenate p_file
'\R'
'000_119481'
sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
sy-uzeit(2) sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
*End of Code for File name
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = p_file
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Short dump - No more storage space available for extending an internal tabl
Hi All,
I have requirement in which my program generates a text file on my presentation server. Here my problem is, this requirement can not be executed in back ground, it should be done in foreground only. When I execute in foreground, if the data records comes to some 38 lacks then I am getting a short dump saying 'No more storage space available for extending an internal table'.
And in dump analysis under WHAT HAPPENED section it is giving as
' What happened? |
| You attempted to extend an internal table, but the required space was |
| not available.
Please suggest me, what I have to do in this case?
Thanks in advance.
Thanks,
Sudha MettuHi SuDash,
Allocation of the memory spaces will be done by BASIS people.
you can contact them..
Regards! -
Problem converting data in XML file to internal table data
Hi all,
I have a requirement. I need to convert an XML file to internal table data and based on that data do Goods Receipt in SAP.
With the help of this blog /people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
I am able to convert the XML file to data in SAP. But this blog will display the output on screen as ELELEMNT = nodename VALUE= value of that node.
But I donu2019t want in that way, I want to store all the data in XML file in an internal table so that I can make use of those values and do Goods Recipt in SAP.
Can some one suggest how should I read the data in an internal table.
Here is my code..what changes should I make?
*& Report z_xit_xml_check
REPORT z_xit_xml_check.
TYPE-POOLS: ixml.
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xmldata TYPE string.
DATA: l_elem TYPE REF TO if_ixml_element,
l_root_node TYPE REF TO if_ixml_node,
l_next_node TYPE REF TO if_ixml_node,
l_name TYPE string,
l_iterator TYPE REF TO if_ixml_node_iterator.
DATA: l_xml_table TYPE TABLE OF t_xml_line,
l_xml_line TYPE t_xml_line,
l_xml_table_size TYPE i.
DATA: l_filename TYPE string.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'c:\temp\orders_dtd.xml'.
Validation of XML file: Only DTD included in xml document is supported
PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
IF pa_val EQ 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
Parse the stream
IF l_parser->parse( ) NE 0.
IF l_parser->num_errors( ) NE 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
PERFORM process_dom USING l_document.
ENDIF.
*& Form get_xml_table
FORM get_xml_table CHANGING l_xml_table_size TYPE i
l_xml_table TYPE STANDARD TABLE.
Local variable declaration
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = pa_file.
upload a file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
ENDFORM. "get_xml_table
*& Form process_dom
FORM process_dom USING document TYPE REF TO if_ixml_document.
DATA: node TYPE REF TO if_ixml_node,
iterator TYPE REF TO if_ixml_node_iterator,
nodemap TYPE REF TO if_ixml_named_node_map,
attr TYPE REF TO if_ixml_node,
name TYPE string,
prefix TYPE string,
value TYPE string,
indent TYPE i,
count TYPE i,
index TYPE i.
node ?= document.
CHECK NOT node IS INITIAL.
ULINE.
WRITE: /.
WRITE: /' DOM-TREE'.
WRITE: /.
IF node IS INITIAL. EXIT. ENDIF.
create a node iterator
iterator = node->create_iterator( ).
get current node
node = iterator->get_next( ).
loop over all nodes
WHILE NOT node IS INITIAL.
indent = node->get_height( ) * 2.
indent = indent + 20.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
IF NOT nodemap IS INITIAL.
attributes
count = nodemap->get_length( ).
DO count TIMES.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
value COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
WRITE: / 'VALUE :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
advance to next node
node = iterator->get_next( ).
ENDWHILE.
ENDFORM. "process_dom
Any help would be highly apperciated.
regards,
Jessica SamPavel Vera,
With your example i tries doing the following .....
I tried to convert the data of XML file to internal table data. I am collecting the data in internal table to do goos recipt with that data.
Please find my XML file, ABAP pgm and XSLT pgm . I donu2019t know what I am missing I am not getting any output. I donu2019t know what is wrong please help me with this
Below is my XML file, My code and XSLT Program. In the below XML file I need to collect Vendor Number, Order Number, and Date tags which occur only once for one XML file.
I also need to collect the following tags from <Shipmentdetail>
<Shipmentdetail> has following child nodes and I need to collect them
TrackingNumber
Freight
Weight
ShipmentDate
ShipmentMethod
Need to collect to collect the following tags from <ProductInformation>
<ProductInformation> has following child nodes and I need to collect them
LineNumber
SKUNumber
OrderedQuantity
ShippedQuantity
UOM
The <Shipmentdetail> and <ProductInformation> are child nodes of <OrderShipment>
The <Shipmentdetail> occurs only ones but the <ProductInformation> can occur once or many times and will be dynamic and differs depening on the input file.
My XML file is as follows
<?xml version="1.0" encoding="iso-8859-1" ?>
- <ShipmentHeader>
<AccountID />
- <OrderShipment>
<VendorNumber>1000</VendorNumber>
<OrderNumber>P00009238</OrderNumber>
<OrderType>Stock</OrderType>
<Company />
<Division />
<Department />
<Date>20061120</Date>
<CartonCount>2</CartonCount>
<ShipAllProducts>No</ShipAllProducts>
- <ShipmentDetail>
<TrackingNumber>1ZR3W891PG47477811</TrackingNumber>
<Freight>000000010000</Freight>
<ShipmentDate>20061120</ShipmentDate>
<ShipmentMethod>UPS1PS</ShipmentMethod>
</ShipmentDetail>
- <ProductInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<OrderedQuantity>00000001000000</OrderedQuantity>
<ShippedQuantity>00000001000000</ShippedQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</ProductInformation>
- <ProductInformation>
<LineNumber>000000002</LineNumber>
<SKUNumber>938EN</SKUNumber>
<AdvSKUNumber>001 7294</AdvSKUNumber>
<SKUID />
<OrderedQuantity>00000000450000</OrderedQuantity>
<ShippedQuantity>00000000450000</ShippedQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</ProductInformation>
- <CaseInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<SSCCNumber>00000001668000002487</SSCCNumber>
<CaseQuantity>00000001000000</CaseQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</CaseInformation>
<CaseInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<SSCCNumber>00000001668000002487</SSCCNumber>
<CaseQuantity>00000001000000</CaseQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</CaseInformation>
- </OrderShipment>
</ShipmentHeader>
My Program
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\temp\test.xml'.
* This is the structure for the data from the XML file
TYPES: BEGIN OF ts_shipment,
VendorNumber(10) TYPE n,
OrderNumber(20) TYPE n,
OrderType(8) TYPE c,
Date(8) TYPE c,
END OF ts_shipment.
TYPES: BEGIN OF ts_shipmentdetail,
TrackingNumber(30) TYPE n,
Freight(12) TYPE n,
Weight(14) TYPE n,
ShipmentDate(8) TYPE c,
ShipmentMethod(8) TYPE c,
END OF ts_shipmentdetail.
TYPES: BEGIN OF ts_productinformation,
LineNumber(9) TYPE n,
SKUNumber(20) TYPE c,
OrderedQuantity(14) TYPE n,
ShippedQuantity(14) TYPE n,
UOM(4) TYPE c,
END OF ts_productinformation.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
* Table and work ares for the data from the XML file
DATA: gt_shipment TYPE STANDARD TABLE OF ts_shipment,
gs_shipment TYPE ts_shipment.
DATA: gt_shipmentdetail TYPE STANDARD TABLE OF ts_shipmentdetail,
gs_shipmentdetail TYPE ts_shipmentdetail.
DATA: gt_productinformation TYPE STANDARD TABLE OF ts_productinformation,
gs_productinformation TYPE ts_productinformation.
* Result table that contains references
* of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
* Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "ISHIPMENT".
GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
gs_result_xml-name = 'ISHIPMENT'.
APPEND gs_result_xml TO gt_result_xml.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "ISHIPDET".
GET REFERENCE OF gt_shipmentdetail INTO gs_result_xml-value.
gs_result_xml-name = 'ISHIPDET'.
APPEND gs_result_xml TO gt_result_xml.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IPRODDET".
GET REFERENCE OF gt_productinformation INTO gs_result_xml-value.
gs_result_xml-name = 'IPRODDET'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION z_xml_to_abap3
SOURCE XML gt_itab
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
* Writing the data from file for gt_shipment
*Collecting the Shipping Data from the XML file to internal table gt_shipment
*and writing the data to the screen
LOOP AT gt_shipment INTO gs_shipment.
WRITE: / 'VendorNumber:', gs_shipment-VendorNumber.
WRITE: / 'OrderNumber :', gs_shipment-OrderNumber.
WRITE: / 'OrderType :', gs_shipment-OrderType.
WRITE: / 'Date :', gs_shipment-Date.
WRITE : /.
ENDLOOP. "gt_shipment.
LOOP AT gt_shipmentdetail INTO gs_shipmentdetail.
WRITE: / 'TrackingNumber:', gs_shipmentdetail-TrackingNumber.
WRITE: / 'Freight :', gs_shipmentdetail-Freight.
WRITE: / 'Weight :', gs_shipmentdetail-Weight.
WRITE: / 'ShipmentDate :', gs_shipmentdetail-ShipmentDate.
* WRITE: / 'ShipmentMethod :' gs_shipmentdetail-ShipmentMethod
WRITE : /.
ENDLOOP. "gt_shipmentdetail.
LOOP AT gt_productinformation INTO gs_productinformation.
WRITE: / 'LineNumber:', gs_productinformation-LineNumber.
WRITE: / 'SKUNumber :', gs_productinformation-SKUNumber.
WRITE: / 'OrderedQuantity :', gs_productinformation-OrderedQuantity.
WRITE: / 'ShippedQuantity :', gs_productinformation-ShippedQuantity.
WRITE: / 'UOM :', gs_productinformation-UOM.
WRITE : /.
ENDLOOP. "gt_productinformation.
XSLT Program
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ISHIPMENT>
<xsl:apply-templates select="//OrderShipment"/>
</ISHIPMENT>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="OrderShipment">
<item>
<VENDORNUMBER>
<xsl:value-of select="VendorNumber"/>
</VENDORNUMBER>
<ORDERNUMBER>
<xsl:value-of select="OrderNumber"/>
</ORDERNUMBER>
<ORDERTYPE>
<xsl:value-of select="OrderType"/>
</ORDERTYPE>
<DATE>
<xsl:value-of select="Date"/>
</DATE>
</item>
</xsl:template>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ISHIPDET>
<xsl:apply-templates select="//OrderShipment/ShipmentDetail"/>
</ISHIPDET>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="ShipmentDetail">
<item>
<TRACKINGNUMBER>
<xsl:value-of select="TrackingNumber"/>
</TRACKINGNUMBER>
<FREIGHT>
<xsl:value-of select="Freight"/>
</FREIGHT>
<SHIPMENTDATE>
<xsl:value-of select="ShipmentDate"/>
</SHIPMENTDATE>
<SHIPMENTMETHOD>
<xsl:value-of select="ShipmentMethod"/>
</SHIPMENTMETHOD>
</item>
</xsl:template>
</xsl:transform> .
Any help is highly appreciated. If anyone encountered this situation before please let me know where i am going wrong in my XSLT transformation.
Any Help will be highly apppreciated. Thanks in advance
Regards,
Jessica Sam -
Sending internal table data to application server as an XML file
Hi All,
I am trying to send the internal table data to application server which should be stored in XML format.
I am using the following code:
DATA:
result TYPE xstring.
CALL TRANSFORMATION id
SOURCE tab = p_output-xsfdata
RESULT XML result.
OPEN DATASET l_xml_full_path FOR OUTPUT IN BINARY MODE.
TRANSFER result TO l_xml_full_path.
CLOSE DATASET l_xml_full_path.
And the content in the internal table is :
3C3F786D6C2076657273696F6E3D22312E30223F3E3C736620786D6C6E733D2275726E3A736
73796D206E616D653D22534653592D44415445223E30362F31302F323030393C2F73796D3E2
50617961626C653C6E65772D6C696E652F3E50617274206F6620746865204E616D653C6E657
.......and so on
With this a file is getting created on the application server, but the data is not correct. I am getting the data something like:
<?xml version="1.0" encoding="utf-8"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><TAB><item>
PD94bWwgdmVyc2lvbj0iMS4wIj8+PHNmIHhtbG5zPSJ1cm46c2FwLWNv
MDA6eHNmIj48c21hcnR4c2Y+PGhlYWRlcj48Z2VuZXJhbD48dmVyc2lvbj4xLjE0LjI8L3ZlcnNp
b24PGZvcm0WkJMX1NESU5WX0xfMzwvZm9ybT48bGFuZ3VhZ2U+RU48L2xhbmd1YWdlPjxkZXZp
Y2UUFJJTlRFUjwvZGV2aWNlPjxvdXRwdXQtZGV2aWNlPlNYU0Y8L291dHB1dC1kZXZpY2UPC9n
ZW5lcmFsPjxwYWdlIG5hbWU9IkZJUlNUIiBpZD0iMDAxIi8PC9oZWFkZXIPGRhdGEgeG1sOnNw
YWNlPSJwcmVzZXJ2ZSIgc3R5bGU9Ii9TTUIxMS9CTF9TRiI+PGdyYXBoaWNzIG5hbWU9IkNPTUxP
R08iIG9iam5hbWU9Ii9TTUI0MC9MRUFGIiBvYmplY3Q9IkdSQVBISUNTIiBpZD0iQk1BUCIgdHlw
ZT0iQkNPTCIgcGFnZT0iRklSU1QiIHBhZ2UtaWQ9IjAwMSIgcmVzb2x1dGlvbj0iMDEwMCIvPjx3
aW5kb3cgbmFtZT0iU0VOREVSIiBwYWdlPSJGSVJTVCIgcGFnZS1pZD0iMDAxIj48dGV4dCBuYW1l
PSJDT01BRERSIiBzdHlsZT0iL1NNQjExL0JMX1NGIiBvYmpuYW1lPSIvU01CMTEvQkxfU0VOREVS
IiBsYW5nPSJFTiIPHAgbmFtZT0iWlMiPkJhc2VsaW5lIENvbXBhbnk8L3APHAgbmFtZT0iWlMi
PjM0NzUgRGVlciBDcmVlazx0YWIvPlBob25lOjx0YWIvPisxICg2NTApIDg0OS00MDAwPC9wPjxw
IG5hbWU9IlpTIj5QYWxvIEFsdG8sIENBIDk0MzA0PHRhYi8+RmF4Ojx0YWIvPisxICg2NTApIDg0
OS00MjAwPC9wPjxwIG5hbWU9IlpTIj5VU0E8dGFiLz5JbnRlcm5ldDo8dGFiLz5odHRwOi8vd3d3
LnNhcC5jb208L3A+PC90ZXh0Pjwvd2luZG93Pjx3aW5kb3cgbmFtZT0iUEFHRSIgcGFnZT0iRklS
U1QiIHBhZ2UtaWQ9IjAwMSI+PHRleHQgbmFtZT0iUEFHRU5VTUJFUiIgc3R5bGU9Ii9TTUIxMS9C
TF9TRiIgbGFuZz0iRU4iPjxwIG5hbWU9IlROIj5QYWdlIDxzeW0gbmFtZT0iU0ZTWS1QQUdFIj4x
PC9zeW0IG9mIDxzeW0gbmFtZT0iU0ZTWS1KT0JQQUdFUyIvPjwvcD48cCBuYW1lPSJUTiIPA==</item>
<item>c3ltIG5hbWU9IlNGU1ktREFURSI+MDYvMTAvMjAwOTwvc3ltPiA8c
RSIMTQ6MDg6MDM8L3N5bT48L3APC90ZXh0Pjwvd2luZG93Pjx3aW5kb3cgbmFtZT0iTkFNRSIg
cGFnZT0iRklSU1QiIHBhZ2UtaWQ9IjAwMSI+PHRleHQgbmFtZT0iRk9STVVMQVJUSVRFTCIgc3R5
bGU9Ii9TTUIxMS9CTF9TRiIgbGFuZz0iRU4iPjxwIG5hbWU9IlROIj48Y2hyIG5hbWU9Ik1MIj48
c3ltIG5hbWU9IlRJVExFIj5JbnZvaWNlPC9zeW0PC9jaHIPC9wPjwvdGV4dD48L3dpbmRvdz48
d2luZG93IG5hbWU9IkJJTExUT1BBUlRZIiBwYWdlPSJGSVJTVCIgcGFnZS1pZD0iMDAxIj48dGV4
dCBuYW1lPSJXSU5ET1dfVEVYVCIgc3R5bGU9Ii9TTUIxMS9CTF9TRiIgbGFuZz0iRU4iPjxwIG5h
bWU9IlRIIj5CaWxsLVRvLVBhcnR5PC9wPjwvdGV4dD48YWRkcmVzcyBuYW1lPSJCSUxMQUREUkVT
UyIgYWRkcm51bWJlcj0iMDAwMDAyMjQyNyI+PHRleHQgbmFtZT0iQklMTEFERFJFU1MiIHN0eWxl
PSIvU01CMTEvQkxfU0YiIGxhbmc9IkVOIj48cCBuYW1lPSJUMiI+VGVjaCBJbmM8bmV3LWxpbmUv
Could anyone tell me the reason why am I getting the data in this way?
Thanks in advance,
Swapna.
Edited by: NagaSwapna Thota on Jun 10, 2009 5:44 PMHI,
Use this FM SAP_CONVERT_TO_XML_FORMAT to convert the data to XML format and then upload the convert data from the internal table to Application server. -
How to send internal table data through mail from report in foreground
hi all,
iam trying to convert the internal table data into excel format and sending it through mail by runnning the report in foreground.
mail is going sucessfully with excel format,but iam facing the problem in the excel format of the material column as follows:
the matrno shows the wrong format -2.63E+11 instead of displaying correct format-263215000000.
Pls suggest the alternative process for the above mentioned problem.
Thanks,
Sivagopal R.Hi Siva,
Try to copy 263215000000 in one of the cells of excel sheet and press enter.It will automatically convert into -2.63E+11 .
This means the default formatting of the excel sheet makes this happen.If you convert the format of the cell to "NUMBER" then u will get the required result.
But I doubt whether or not it is possible through ABAP programming.
Regards,
Vimal. -
How to Convert internal table data into text output and send mail in ABAP
Hi All,
Good Morning.
Taking a glance at a code that converts internal table data to an Excel file in ABAP. also checked how to send this excel to mailing list as attachment.
But thought of doing it without excel.
I mean, I have an internal table which contains fields of all types (character,integer,date,time). Since it is only around 4 to 5 rows in it (output),why to convert it to excel. not required!!. Instead I want to send this output to User's mails as Normal mail body with No attachments.
Could anybody please suggest me a way as to how to send internal table data as a mail ( not as an excel or PDF etc).
as of now my findings are, it is quite complex to convert internal table data to email (Text) format. but i believe if there is some way of doing it.
Best Regards
Dileep VThere's something I have used in the past where we send out information about failed precalculation settings (which are stored in internal table gt_fail)
notice we use gt_text as "mail body"
TRY.
* -------- create persistent send request ------------------------
gv_send_request = cl_bcs=>create_persistent( ).
* -------- create and set document -------------------------------
* create text to be sent
wa_line = text-001.
APPEND wa_line TO gt_text.
CLEAR wa_line.
APPEND wa_line TO gt_text.
LOOP AT gt_fail ASSIGNING <fs_fail>.
MOVE <fs_fail>-retry_count TO gv_count.
CONCATENATE text-002
<fs_fail>-setting_id
text-003
gv_count
INTO wa_line SEPARATED BY space.
APPEND wa_line TO gt_text.
CLEAR wa_line.
ENDLOOP.
APPEND wa_line TO gt_text.
wa_line = text-007.
APPEND wa_line TO gt_text.
* create actual document
gv_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = gt_text
i_length = '12'
i_subject = 'Failed Precalculation Settings!' ).
* add document to send request
CALL METHOD gv_send_request->set_document( gv_document ).
* --------- set sender -------------------------------------------
gv_sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD gv_send_request->set_sender
EXPORTING
i_sender = gv_sender.
* --------- add recipient (e-mail address) -----------------------
LOOP AT s_email INTO wa_email.
MOVE wa_email-low TO gv_email.
gv_recipient = cl_cam_address_bcs=>create_internet_address(
gv_email ).
CALL METHOD gv_send_request->add_recipient
EXPORTING
i_recipient = gv_recipient
i_express = 'X'.
ENDLOOP.
* ---------- set to send immediately -----------------------------
CALL METHOD gv_send_request->set_send_immediately( 'X' ).
* ---------- send document ---------------------------------------
CALL METHOD gv_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = gv_sent_to_all ).
IF gv_sent_to_all = 'X'.
WRITE text-004.
ENDIF.
COMMIT WORK.
* exception handling
CATCH cx_bcs INTO gv_bcs_exception.
WRITE: text-005.
WRITE: text-006, gv_bcs_exception->error_type.
EXIT.
ENDTRY.
with the following declarations
* TABLES *
TABLES:
adr6,
rsr_prec_sett.
* INTERNAL TABLES & WORK AREAS *
DATA:
gt_fail TYPE SORTED TABLE OF rsr_prec_sett
WITH UNIQUE KEY setting_id run_date,
gt_text TYPE bcsy_text,
wa_fail LIKE LINE OF gt_fail,
wa_line(90) TYPE c.
FIELD-SYMBOLS:
<fs_fail> LIKE LINE OF gt_fail.
* VARIABLES *
DATA:
gv_count(4) TYPE n,
gv_send_request TYPE REF TO cl_bcs,
gv_document TYPE REF TO cl_document_bcs,
gv_sender TYPE REF TO cl_sapuser_bcs,
gv_recipient TYPE REF TO if_recipient_bcs,
gv_email TYPE adr6-smtp_addr,
gv_bcs_exception TYPE REF TO cx_bcs,
gv_sent_to_all TYPE os_boolean.
* SELECTION-SCREEN *
SELECT-OPTIONS:
s_email FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.
DATA:
wa_email LIKE LINE OF s_email. -
How to Populate Internal table data to Table Control in a Report Program
Dear All,
How to Populate Internal table data to Table Control in a Report Program? It is a pure report program with out any Module pool coding involved, which is just used to display data. Till now it is being displayed in a report. Now the user wants the data to be displayed in a table control. Could someone tell me how to go about with this.
Thanks in Advance,
Joseph ReddyIf you want to use a table control, you will need to create a screen.
In your report....
start-of-selection.
perform get_data. " Get all your data here
call screen 100. " Now present to the user.
Double click on the "100" in your call screen statement. This will forward navigate you to the screen. If you have not created it yet, it will ask you if you want to create it, say yes. Go into screen painter or layout of the screen. Use the table control wizard to help you along the process. It will write the code for you. Since it is an output only table control, it will be really easy with not a lot of code.
A better way to present the data to the user would be to give it in a ALV grid. If you want to go that way, it is a lot easier. Here is a sample of the ALV function module. You don't even have to create a screen.
report zrich_0004
no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: begin of imara occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of imara.
* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
* Get_Data
form get_data.
select mara~matnr makt~maktx
into corresponding fields of table imara
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
* WRITE_REPORT
form write_report.
perform build_field_catalog.
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
tables
t_outtab = imara.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat. refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material'.
fc_tmp-fieldname = 'MAKTX'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '40'.
fc_tmp-col_pos = 3.
append fc_tmp to fieldcat.
endform.
Regards,
Rich Heilman
Maybe you are looking for
-
Apps not working on HP photosmart 7520
Hello.. New here so apologies if iv posted this in the wrong place! Iv just purchased a photosmart 7520 all in one printer and everything on it works perfectly apart from the apps on the touch screen. Everytime i touch an app or touch the icon to get
-
How to track network speeds - maybe through SQL or open to others
The network speed is dramatically slower to the SAN, but it also makes me wonder how slow things are between the Webserver and the external world. What's the best way to monitor what-I-assume are network delays and which part of the networks are caus
-
Ever so randomly about 3 weeks ago my audio started stuttering through itunes. I've done some looking around and discovered the problem was somewhat widespread and have experiemented with all the different possible fixes. Checking off the SafeMode (w
-
Is it possible somehow get the Camera "light" off ...
So...Always when i take picture with my N8 it flashes the red light...its really annoying...And in options there aint no thing for turn this off. Does anyone now anyother solution? This same light is almost on every nokia phone...If somebody doesnt k
-
Hello, I am trying to use the Khmer fonts and keyboard layout that came with my MacBookPro. They were available to me through the Langauge & Text preferences in Settings. My question is, how do I type the sub-consonants or feet of the consonants.