Move the data in select options to internal table
I have the code as in the fillowing
SELECT-OPTION:S_MATNR FOR MARA-MATNR.
DATA:BEGIN OF IT_MATNTR OCCURS 0,
MATNR LIKE MARA-MATNR,
END OF IT-MATNR.
NOW HOW CAN I ADD THE MATNER VALUES IN THE SELECT-OPTIONS IN INTERNAL TABLE
Hi Vamsikrishna,
Yes. You can move the values from S_MATNR to IT_MATNR.
you can try either it_matnr[] = s_matnr[].
if not then you can loop in to the select-options as follows.
Define LS_MATNR as a structure type of s_matnr.
Define LS_IT_MATNR as a structure type of it_matnr.
LOOP S_MATNR INTO LS_MATNR.
MOVE LS_MATNR to LS_IT_MATNR.
APPEND LS_IT_MATNR to IT_MATNR.
CLEAR: LS_MATNR, LS_IT_MATNR.
ENDLOOP.
<b>Reward points for helpful answers.</b>
Best Regards,
Ram.
Similar Messages
-
How to get all values in the range of select option into internal table?
Hi,
I need to capture all entries coming in the range of select option into one internal table.
How to do get that?
For E.g
select-options: matnr for mara-matnr.(select option)
IF I enter G0100013507892 as lower value of matnr and G0100014873947 as higher value
and if there are 10,000 materials in the above range, then I want to capture all theses 10000 materails in one internal table. How to do that?
Regards,
MrunalHello Mrunal Mhaskar ,
What i understand you can do one thing go in debug mode
Try this code : -
LOOP AT s_matnr_ex.
IF s_matnr_ex-low IS NOT INITIAL.
i_matnr-matnr = s_matnr_ex-low.
i_matnr-option = s_matnr_ex-option.
APPEND i_matnr.
CLEAR : i_matnr.
ENDIF.
ENDLOOP.
LOOP AT s_matnr_ex.
IF s_matnr_ex-high IS NOT INITIAL.
i_matnr-matnr = s_matnr_ex-high.
i_matnr-option = s_matnr_ex-option.
APPEND i_matnr.
CLEAR : i_matnr.
ENDIF.
ENDLOOP.
In the i_matnr table high and low values are there.
Regards,
Vandana. -
Passing SELECT-OPTIONS and Internal Tables to SUBROUTINES
Hi Guys
In the code below my colleague has created her own table types in order to pass a select option and internal tables to her subroutine. Is there an easier way of making them known to the subroutine.
data : v_vbeln type vbeln_vf,
it_bdoc type table of vbrp,
it_t006 type table of t006a,
wa_bdoc type vbrp,
wa_t006 type t006a,
it_bdoc2 type table of zsswathi_st_vbeln,
wa_bdoc2 type zsswathi_st_vbeln
select-options s_vbeln for v_vbeln matchcode object zswathi_vbeln obligatory.
start-of-selection.
perform bdoc using s_vbeln[]
changing it_bdoc
it_bdoc2
it_t006.
loop at it_bdoc2 into wa_bdoc2.
form bdoc using f_s_vbeln type ZSWATHI_ST_SELECT_OPTION_TA_TY " all these are table types. for select options, a structure is created and then a table type for it is created.
changing f_it_bdoc type zswathi_vbrp_ty_ta
f_it_bdoc2 type zswathi_vbeln_ty_ta
f_it_t006 type ZSWATHI_T006_TA_TY.
select * from vbrp into table f_it_bdoc where vbeln in f_s_vbeln.
if f_it_bdoc is not initial.
select vbeln sum( netwr ) prsdt from vbrp into table f_it_bdoc2 where vbeln in f_s_vbeln group by vbeln prsdt.
sort f_it_bdoc2 by vbeln.
"select * from t006a into table it_t006 for all entries in it_bdoc where msehi = it_bdoc-vrkme.
select * from t006a into table f_it_t006 for all entries in f_it_bdoc where msehi = f_it_bdoc-vrkme.
endif.
endform.Hi Brett,
1. you can use a select-options-range in a FORM subroutine also without passing it as a parameter because parameters and select-option range tables are global fields in their program.
2. If you need a parameter, declare it as type table or type standard table or type any table. You do not need any special table type.
Regards
Clemens -
Cant't get the data through SELECTION-OPTION
hi all,
i have created a REPORT in which i have two SELECTION-OPTION i-e one is ANLKL from TABLE ANLA and other is GJAHR from table ANLC.Problem which i m facing is that when i execute without giving my SELECTION-OPTION GJAHR.it gives me all data for example(2005,2007,2008),but when im defining it with by 2005 it gives blank fields even though there is data with GJAHR by 2005.
This is the coding of my report:
include zalsd_alv_incl.
TABLES:ANEP,ANLA,ANLC.
SELECT-OPTIONS:
S_ANLKL FOR ANLA-ANLKL DEFAULT '1100' to '2790',
S_GJAHR FOR ANLC-GJAHR.
DATA:BEGIN OF gi_anla OCCURS 0,
bukrs LIKE anla-bukrs,
ANLN1 LIKE anla-ANLN1,
ANLN2 LIKE anla-ANLN2,
AKTIV LIKE ANLA-AKTIV,"Asset capitalization date
ANLKL LIKE ANLA-ANLKL,"Asset Class
END OF gi_anla,
BEGIN OF GI_ANLC OCCURS 0,
bukrs LIKE anlc-bukrs,
NAFAP LIKE anlc-nafag,"Posted Depreciation
kansw LIKE anlc-kansw,"Asset Acquisation Value
ANLN2 LIKE anlc-anln2,"Asset Subnumber
ANLN1 LIKE anlc-ANLN1,"Main Asset Number
GJAHR LIKE ANLC-GJAHR,"Fiscal Year
AFABE LIKE ANLC-AFABE,"Real depreciation area
ANSWL LIKE ANLC-ANSWL,"Transactions for the year
END OF GI_ANLC,
BEGIN OF gi_main OCCURS 0,
sno type i, "S.No
bukrs LIKE anla-bukrs,"Company code
ANLN1 LIKE anlc-ANLN1,"Main Asset Number
anln2 LIKE anlc-anln2,"Asset Subnumber
AKTIV LIKE ANLA-AKTIV,"Asset capitalization date
ANLKL LIKE ANLA-ANLKL,"Asset Class
NAFAG LIKE anlc-nafag,"Ordinary Depreciation Posted
kansw LIKE anlc-kansw,"Asset Acquisation Value
GJAHR LIKE ANLC-GJAHR,"Fiscal Year
PSTEND LIKE anlc-PSTEND,"Posting depreciation up to period
AFABE LIKE ANLC-AFABE,"Real depreciation area
ANSWL LIKE ANLC-ANSWL,"Transactions for the year
END OF gi_main.
START-OF-SELECTION.
PERFORM get_data.
PERFORM organize_data.
PERFORM f_display_report.
END-OF-SELECTION.
form get_data.
SELECT anlc~bukrs anlc~anln1 ANLC~ANLN2 kansw nafaG PSTEND ANSWL ANLKL AKTIV
INTO CORRESPONDING FIELDS OF TABLE gi_main
FROM
ANLC
INNER JOIN ANLA ON
anlc~bukrs = anla~bukrs AND
anlc~anln1 = anla~anln1 AND
ANLC~ANLN2 = ANLA~ANLN2
WHERE AFABE eq '1'
AND GJAHR IN S_GJAHR
AND ANLA~ANLKL in S_ANLKL.
ENDFORM.
FORM organize_data.
data: lv_index type sy-tabix.
LOOP at gi_anla.
move sy-tabix to gi_main-sno.
READ TABLE gi_anla WITH KEY bukrs = gi_anla-bukrs
anln1 = gi_anla-anln1
anln2 = gi_anla-anln2.
MOVE-CORRESPONDING gi_anla to gi_main.
READ TABLE gi_anlc WITH KEY bukrs = gi_anlc-bukrs
anln1 = gi_anlc-anln1
anln2 = gi_anlc-anln2.
IF sy-subrc = 0.
MOVE-CORRESPONDING gi_anlc to gi_main.
ENDIF.
APPEND gi_main.
CLEAR gi_main.
ENDLOOP.
ENDFORM.
form f_display_report.
perform fill_fieldcat using 'SNO' 5 'S.No.' 'gi_main'.
perform fill_fieldcat using 'ANLKL' 20 'Asset Class' 'gi_main'.
perform fill_fieldcat using 'ANLN1' 20 'Asset Number' 'gi_main'.
perform fill_fieldcat using 'ANLN2' 20 'Asset Subnumber' 'gi_main'.
perform fill_fieldcat using 'AKTIV' 20 'Asset Capitalization Date' 'gi_main'.
perform fill_fieldcat using 'KANSW' 20 'Asset Acquisation Value' 'gi_main'.
perform fill_fieldcat using 'NAFAG' 20 'Posted Depreciation' 'gi_main'.
perform fill_fieldcat using 'PSTEND' 20 'Posting depreciation up to period' 'gi_main'.
perform fill_fieldcat using 'ANSWL' 20 'Transactions for the year' 'gi_main'.
perform add_heading_alv using c_alv_head_header '' 'Ghulam Farooq Group'.
perform display_alv using gi_main[].
endform.
Thankks,
abapfkHi,
I created a program with the 2 select-option and a structure for storage and a select statement.
REPORT Z_ANLA_ANLC_TEST.
TABLES:ANEP,ANLA,ANLC.
SELECT-OPTIONS:
S_ANLKL FOR ANLA-ANLKL DEFAULT '1100' to '2790',
S_GJAHR FOR ANLC-GJAHR.
DATA :
BEGIN OF gi_main OCCURS 0,
sno type i, "S.No
bukrs LIKE anla-bukrs,"Company code
ANLN1 LIKE anlc-ANLN1,"Main Asset Number
anln2 LIKE anlc-anln2,"Asset Subnumber
AKTIV LIKE ANLA-AKTIV,"Asset capitalization date
ANLKL LIKE ANLA-ANLKL,"Asset Class
NAFAG LIKE anlc-nafag,"Ordinary Depreciation Posted
kansw LIKE anlc-kansw,"Asset Acquisation Value
GJAHR LIKE ANLC-GJAHR,"Fiscal Year
PSTEND LIKE anlc-PSTEND,"Posting depreciation up to period
AFABE LIKE ANLC-AFABE,"Real depreciation area
ANSWL LIKE ANLC-ANSWL,"Transactions for the year
END OF gi_main.
START-OF-SELECTION.
SELECT anlcbukrs anlcanln1 ANLC~ANLN2 kansw nafaG PSTEND ANSWL ANLKL AKTIV
INTO CORRESPONDING FIELDS OF TABLE gi_main
FROM
ANLC
INNER JOIN ANLA ON
anlcbukrs = anlabukrs AND
anlcanln1 = anlaanln1 AND
ANLCANLN2 = ANLAANLN2
WHERE AFABE eq '1'
AND GJAHR IN S_GJAHR
AND ANLA~ANLKL in S_ANLKL.
BREAK-POINT.
Here is the result at the break point
GI_MAIN[] Standard Table[831x12(116)]
S_ANLKL[] Standard Table[0x4(38)]
S_GJAHR[] Standard Table[1x4(22)]
S_GJAHR-LOW 2009
S_GJAHR-HIGH 0000
I entered value only in GJAHR.
I see there is no problem with the JOIN and the selection, i assume there is a problem with the data.
Try creating a simple query using sqvi and check it.
Regards,
George. -
How to get the data into select options if we have 10 select options
Hi Experts,
I facing problem to get the data from diffrent tables and different select options.
I have to pass different parameter ranges.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: rb1 RADIOBUTTON GROUP g1. "Existing Key Accounts
PARAMETERS: rb2 RADIOBUTTON GROUP g1. "Potential Key Accounts
SELECT-OPTIONS: s_part FOR but000-partner."Business Partner Number
PARAMETERS: p_bpkind LIKE but000-bpkind. "Business Partner Type
PARAMETERS: p_but000 LIKE but000-partner. "Key Account Manager
SELECT-OPTIONS : s_vkont FOR fkkvkp-vkont. "Contract Account
SELECT-OPTIONS : s_ktokl FOR fkkvkp-ktokl. "Debtor Type
SELECT-OPTIONS : s_sparte FOR ever-sparte. "Division
SELECT-OPTIONS : s_vertra FOR ever-vertrag. "Contract
SELECT-OPTIONS : s_budat FOR erdk-budat. "Invoice Date
SELECT-OPTIONS : s_netto FOR dberchv-nettobtr."Billing Amount
SELECT-OPTIONS : s_abrm FOR abc. "Consumption Value
SELECTION-SCREEN: END OF BLOCK b1.
need response asap.
Thanking you.
Regards Surya RamireddyHI,
You can use as many Select-options in the select statment,
Select XXXX yyyy from TABLE where FIELD In S_FIELD1 and
FIELD2 In S_FIELD2.
Regards
Sudheer -
SELECT-OPTION to internal table
Hi,
I need to convert the select-option values into an internal table.
For example, if there is a select-option S_WERKS... i need all the values entered for S_WERKS into the internal table. The internal table structure contains only WERKS.
My actual requirement is, for the given plant values as select-option, i need to fetch all details of the plants. And I should not use any SELECT statements at any stage. Only through function module/ BAPI/BADI/Class methods.
I found one function module T001W_READ, but i need to pass the plant for that.
Please suggest.
Thanks in advance.
kishoreHi Kishore
Why can't you use any SELECTs? If it is so required why not writing your own FM to select them? You can pass your select-option via a generic parameter and assign it to a range at the beginning of your FM. Or you can assign it to a select-option-like table (you can find structure names of similar type from DDIC)
<i><b>e.g.</b></i>
TABLES t001w .
RANGES s_werks for t001w-werks .
DATA: BEGIN OF lt_werks ,
werks LIKE t001w-werks ,
END OF lt_werks .
s_werks[] = it_werks_so[] .
SELECT werks FROM t001w
INTO lt_werks
WHERE werks IN s_werks .
As another thing, let me introduce you the SDN Forums pointing system: You can assign points to posts which you find helpful while solving your problem. You can reward points by pressing the yellow star icon at header of each post. You can assign;
- one 10 points (solved)
- two 6 points (very helpful answer)
- many 2 points (helpful answer)
*--Serdar -
Select options to internal table
i have selected some values in the range say 100 to 200 using select options....is there any way to get these values in an internal table?
also does select option work with alpha numeric values
eg : if i want to select between a100 and b200?>
VR ARVIND wrote:
> i mean to say if i have 100 to 200.. i need 101 102 103 etc..continuosly till 200
Select-options are really only useful for selecting data that matches the select-options from some other dataset. They don "expand out" into a set of values.
If you are always specifying a range in the selection screen, use two parameters - p_low, p_high.
You then will need to build your itab entry by entry. So
l_count = p_low.
WHILE l_count LE p_high.
INSERT l_count INTO t_itab.
ADD 1 to l_count.
ENDWHILE.
For a100 to a200, you'd have to do some string slicing and concatenation to get the desired result. -
Create select-options using internal table
Hello,
I have number of table-fields in one internal table.
I need to create select-options on screen for each of the table field in that internal table.
Can anybody please provide a code for it ?
Thanks.hi,
you can create in this way :
select-options: <name> for itab-<field name>.
example code:
TABLES: vbak. " standard table
TYPE-POOLS: slis.
*-- Structure to hold data from table
TYPES: BEGIN OF tp_itab1,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
werks LIKE vbap-werks,
lgort LIKE vbap-lgort,
END OF tp_itab1.
*-- Data Declaration
DATA: t_itab1 TYPE TABLE OF tp_itab1.
DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
* Selection Screen *
*--Sales document-block
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln,
s_posnr FOR vbap-posnr,
s_werks FOR vbap-werks,
s_lgort FOR vbap-lgort.*
SELECTION-SCREEN END OF BLOCK b1.
hope it will help you
regards
Rahul sharma
Edited by: RAHUL SHARMA on Sep 19, 2008 8:25 AM -
Select options and internal table
Hi,
I have requirement for which I was coding...
On the selction screen, I have an object field... say I have multiple values like 101, 102, 103
select-options: s_3 for hrp1000-objid.
i_1001 type standard table of HRP1001 with header line
i_temp_1001 type standard table of HRP1001 occurs 0.
Need to create an hrp1001 record for these based on a template record available in hrp1001.
I need to read all the records of the template record (say 100) from hrp1001 and need to create the same set for the objects 101, 102 and 103. How to do that? ofcourse I need to replace the object id 100 with 101, 102 and so on for the complte set..
How can I accomplish without using nested loops.
tried something like this..
select * from HRP1001 into corresponding fields of i_1001 where otype = '51' and objid = '100' and endda = '99991231'.
if sy-subrc = 0.
clear i_hrp1000-objid.
append i_1001.
endselect.
loop at s_3.
loop at i_1001.
move-corresponding i_1001 to i_temp_1001.
endloop.
i_temp_1001-objid = s_brd3-low.
append i_temp_1001.
endloop..
Looking to avoid nested loops... Any thoughts?
Thanks,
VGModerator message -
When closing old threads, there is no need to add a comment. Adding a pasted answer like "Resolved myself " only brings old threads to the top of the forum list and pushes current ones down. If you do add a comment, please indicate just how the problem was resolved.
And please use code tags to format code.
Rob -
How do I extract the data of Variant configuration into internal tables
Hi Experts,
How can I extract the data of variant configuration into an internal tables while preparing the report.
Thanks,
bsv.Hi i´m not a "Expert.." but may I can help you:
CUCB_GET_VALUES_FROM_INSTANCE
Example:
Instance = MARA-CUOBF or
Instance = lips-cuobj
Result is the data of the Variant tables.
I need that for a simple report to evaluate customer & and his Variants......
Robert -
Validate the data in the internal table with the date in selection screen
Hi all,
I want to validate the data in the internal table and get only the records with the input date in the selection screen.
The date is in the select options and please let me know how to get the records only if it satisfies the input date in the selection screen.
Regards,
ShalemFor Ex.
SELECT-OPTIONS: S_DATE FOR VBAK-VDATU
If you want to read one INTERNAL TABLE record
READ TABLE it_tab(internal table name) WHERE vdatu(date field name in the internal table) = s_date
If you want to move more then one
LOOP AT it_tab WHERE vdatu = s_date.
Take the field values in another table and append it. then end loop.
you will get the records which only have the date in select option..
If you want detail code give me internal table name and select option name i will write you the code.
regards
Yuvaram -
Change the Parameter as Select option
Hi Guy's,
Please help me friends, present requirement is like this : change the Parameter into Select-Option.
Here they are using one function module, this function module import parameter taking single value, how loop this function module with in this select-option.
PARAMETERS p_fictr LIKE fmfctr-fictr.
START-OF-SELECTION.
Move the select options to internal tables (import parameter for fn)
move_sel_option : sel_buk s_bukrs ,
sel_pern s_pernr ,
sreinr s_reinr ,
spdatv s_pdatv ,
sberei s_berei .
Call the function to get all trips corresponding to sel criteria
CALL FUNCTION 'ZHR_GET_FUND_TRIPS'
EXPORTING
p_fictr = p_fictr
p_sub = p_sub
TABLES
s_bukrs = s_bukrs
s_pernr = s_pernr
s_reinr = s_reinr
s_pdatv = s_pdatv
s_berei = s_berei
i_trip = i_trip
EXCEPTIONS
OTHERS = 1.
Thanks and Regards,
Saihi,
You can first the field values using the select statement and then loop that internal table and pass the values to the function module.
try this
*PARAMETERS p_fictr LIKE fmfctr-fictr.
select-options: s_fictr for fmfctr-fictr.
START-OF-SELECTION.
Move the select options to internal tables (import parameter for fn)
move_sel_option : sel_buk s_bukrs ,
sel_pern s_pernr ,
sreinr s_reinr ,
spdatv s_pdatv ,
sberei s_berei .
select fictr
from fmfctr
into tabel itab
where fictr in s_fictr.
loop at itab.
Call the function to get all trips corresponding to sel criteria
CALL FUNCTION 'ZHR_GET_FUND_TRIPS'
EXPORTING
*p_fictr = p_fictr
p_fictr = itab-fictr
p_sub = p_sub
TABLES
s_bukrs = s_bukrs
s_pernr = s_pernr
s_reinr = s_reinr
s_pdatv = s_pdatv
s_berei = s_berei
i_trip = i_trip
EXCEPTIONS
OTHERS = 1.
endloop.
regards,
Veeresh -
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 -
I am moving from PC to Mac. My PC has two internal drives and I have a 3Tb external. What is best way to move the data from the internal drives to Mac and the best way to make the external drive read write without losing data
Paragon even has non-destriuctive conversion utility if you do want to change drive.
Hard to imagine using 3TB that isn't NTFS. Mac uses GPT for default partition type as well as HFS+
www.paragon-software.com
Some general Apple Help www.apple.com/support/
Also,
Mac OS X Help
http://www.apple.com/support/macbasics/
Isolating Issues in Mac OS
http://support.apple.com/kb/TS1388
https://www.apple.com/support/osx/
https://www.apple.com/support/quickassist/
http://www.apple.com/support/mac101/help/
http://www.apple.com/support/mac101/tour/
Get Help with your Product
http://docs.info.apple.com/article.html?artnum=304725
Apple Mac App Store
https://discussions.apple.com/community/mac_app_store/using_mac_apple_store
How to Buy Mac OS X Mountain Lion/Lion
http://www.apple.com/osx/how-to-upgrade/
TimeMachine 101
https://support.apple.com/kb/HT1427
http://www.apple.com/support/timemachine
Mac OS X Community
https://discussions.apple.com/community/mac_os -
How to get the values of Select-options from the screen.
The value of parameter can be obtained by function module 'DYNP_VALUES_READ' but How to get the values of Select-options from the screen? I want the F4 help values of select-options B depending on the values in Select-option A.So I want to read the Select-option A's value.
Hi,
Refer this following code..this will solve your problem...
"Following code reads value entered in s_po select options and willprovide search
"help for s_item depending upon s_po value.
REPORT TEST.
TABLES : ekpo.
DATA: BEGIN OF itab OCCURS 0,
ebelp LIKE ekpo-ebelp,
END OF itab.
SELECT-OPTIONS s_po FOR ekpo-ebeln.
SELECT-OPTIONS s_item FOR ekpo-ebelp.
INITIALIZATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_item-low.
DATA:
dyn_field TYPE dynpread,
temp_fields TYPE TABLE OF dynpread,
zlv_dynpro TYPE syst-repid.
zlv_dynpro = syst-repid.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = zlv_dynpro
dynumb = syst-dynnr
request = 'A'
TABLES
dynpfields = temp_fields
EXCEPTIONS
OTHERS = 0.
LOOP AT temp_fields INTO dyn_field.
IF dyn_field-fieldname EQ 'S_PO-LOW'.
SELECT * INTO CORRESPONDING fields OF TABLE itab FROM ekpo
WHERE ebeln EQ dyn_field-fieldvalue.
EXIT.
ENDIF.
ENDLOOP.
Maybe you are looking for
-
Is there a way to create a password protected folder for pictures or lock the photos app? I want to do this for Ipad air and Iphone 5s. I have other family members that use my Ipad and Iphone and do not want some pictures to be able to be viewed. Tha
-
Error when creating BufferedImage with IndexColorModel from a byte array.
Hi, I have a 1-dimentional byte array and an IndexColorTable, and I can't figure out how to combine the 2 into an BufferedImage without unnecessary copying/reallocating of the image buffer. The color model I have is: int [] cmap = new int [numColors]
-
Hp deskjet F380 all in one printer
How do I install drives for my hp deskjet f380 printer?
-
Re-installed CS3 and Bridge does not appear...?
I was having major issues with Bridge (slow-moving, then crashing and finally an inability to open altogether). I tried a c number of things like clearing caches, repairing permissions etc. In the end, I uninstalled Photoshop CS3 and deleted all Br
-
JTextPane + Getting a row count..
Hi, I've been looking for a solution to this, but can't find one already in the forum. there are some close .. but this is my problem.. I'm looking to get the current row count of a JTextPane... I'm not looking to get the count of '\n'.... I want to