Internal table - select if in range ?
Hello ABAP Experts,
I have a internal i_gl_account table which has some of the following fields:
glacctfrom, glacctto, flag
i have to select a record from this internal table based on a fixed gl_account_fix.
i cannot write this statement
read table i_gl_account with key
glacctfrom >= gl_account_fix
glacctto <= gl_account_fix
since read does not allow the '>' or '<' operators.
one alternative possible is:
loop i_gl_account.
if ( glacctfrom >= gl_account_fix and
glacctto <= gl_account_fix).
exit.
endif.
endloop.
This solutions, lookups at each and every record one by one and then does the if comparisions. Incase the i_gl_account is large then this is huge cost and processing.
wondering if there is any other possible method of achieving the same with lesser processing and cost.
Any suggetions are appreciated.
Thanks,
BWer
You could also something simular to this sample program. If know that the start point is in the table. Here the program is reading the first line where the start value is =, then it is reading each line after that untill it reaches the end point. But it is not reading the entire internal table.
report zrich_0001.
data: begin of itab occurs 0,
field1(10) type c,
field2(10) type c,
field3(10) type c,
end of itab.
itab-field1 = 'A'.
itab-field2 = '1'.
itab-field3 = '001'.
append itab.
itab-field1 = 'A'.
itab-field2 = '2'.
itab-field3 = '123'.
append itab.
itab-field1 = 'A'.
itab-field2 = '3'.
itab-field3 = '124'.
append itab.
itab-field1 = 'A'.
itab-field2 = '4'.
itab-field3 = '125'.
append itab.
itab-field1 = 'A'.
itab-field2 = '5'.
itab-field3 = '999'.
append itab.
sort itab ascending by field1 field2 field3.
data: index type sy-index.
data: start like itab-field3 value '123'.
data: end like itab-field3 value '125'.
read table itab with key field3 = start.
if sy-subrc = 0.
write:/ itab-field1, itab-field2, itab-field3.
index = sy-tabix + 1.
while sy-subrc = 0.
read table itab index index.
if sy-subrc = 0
and itab-field3 <= end.
write:/ itab-field1, itab-field2, itab-field3.
else.
sy-subrc = 4.
endif.
index = index + 1.
endwhile.
endif.
Regards,
Rich Heilman
Similar Messages
-
Internal tables & select query for clasical report
hello all,
i am a novice in ABAP.i need to retrive data from 4 DB tables to do a classical report. i declared internal tables as below and then retrieved the data as per the below select statements. is there any other way in which i can do the same with a comparitively lesser amt of code.
data: begin of i_vbak occurs 0,
vbeln like vbak-vbeln,
kunnr like vbak-kunnr,
waerk like vbak-waerk,
end of i_vbak.
data: begin of i_vbap occurs 0,
vbeln like vbap-vbeln,
kwmeng like vbap-kwmeng,
posnr like vbap-posnr,
vrkme like vbap-vrkme,
netpr like vbap-netpr,
end of i_vbap.
data: begin of i_lips occurs 0,
vbeln like lips-vbeln,
vgpos like lips-vgpos,
vrkme like lips-vrkme,
lfimg like lips-lfimg,
end of i_lips.
data: begin of i_vbep occurs 0,
vbeln like vbep-vbeln,
posnr like vbep-posnr,
edatu like vbep-edatu,
end of i_vbep.
data: begin of i_out occurs 0,
kunnr like vbak-kunnr,
vbeln like vbak-vbeln,
kwmeng like vbap-kwmeng,
netpr like vbap-netpr,
waerk like vbak-waerk,
vrkme like vbap-vrkme,
lfimg like lips-lfimg,
posnr like vbep-posnr,
edatu like vbep-edatu,
end of i_out.
RETRIVING THE DATA INTO INTERNAL TABLE *
select vbeln kunnr waerk from vbak into table i_vbak where kunnr in
s_kunnr and vbeln in s_vbeln.
select vbeln kwmeng posnr vrkme netpr from vbap into table i_vbap for
all entries in i_vbak where vbeln = i_vbak-vbeln.
select vbeln vgpos vrkme lfimg from lips into table i_lips for all
entries in i_vbak where vbeln = i_vbak-vbeln and vgpos in s_vgpos.
select vbeln posnr edatu from vbep into table i_vbep for all entries in
i_vbak where vbeln = i_vbak-vbeln.
<b>Points are guaranteed for good answers.</b>
Thanks in advance
seenuHi,
If u will use in ALV means how many tables u want u can put it. After that u can maintain one internal table that's enough. Afterthat put select queries after that display the internal table fileds.
If u will ALV report means u have to code same coding for every report slight changes only there.
Herewith i am sending sample ALV REPORT it is useful for u.
REPORT CODING:
REPORT YMS_COLOURALV NO STANDARD PAGE HEADING.
TYPE-POOLS: SLIS, ICON.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: BEGIN OF IMARA OCCURS 0,
LIGHT(4) TYPE C,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKT-MAKTX,
COLOR_LINE(4) TYPE C,
TCOLOR TYPE SLIS_T_SPECIALCOL_ALV, "cell
END OF IMARA.
DATA: XCOLOR TYPE SLIS_SPECIALCOL_ALV.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM WRITE_REPORT.
Get_Data
FORM GET_DATA.
WRITE ICON_GREEN_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'ABC'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for ABC'.
APPEND IMARA.
WRITE ICON_YELLOW_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'DEF'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for DEF'.
APPEND IMARA.
WRITE ICON_RED_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'GHI'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for GHI'.
APPEND IMARA.
LOOP AT IMARA.
IF SY-TABIX = 1.
IMARA-COLOR_LINE = 'C410'. " color line
ENDIF.
IF SY-TABIX = 2. " color CELL
CLEAR XCOLOR.
XCOLOR-FIELDNAME = 'MTART'.
XCOLOR-COLOR-COL = '3'.
XCOLOR-COLOR-INT = '1'. " Intensified on/off
XCOLOR-COLOR-INV = '0'.
APPEND XCOLOR TO IMARA-TCOLOR.
ENDIF.
MODIFY IMARA.
ENDLOOP.
ENDFORM. "get_data
WRITE_REPORT
FORM WRITE_REPORT.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
LAYOUT-COLTAB_FIELDNAME = 'TCOLOR'.
LAYOUT-INFO_FIELDNAME = 'COLOR_LINE'.
PERFORM BUILD_FIELD_CATALOG.
CALL ABAP LIST VIEWER (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDCAT
TABLES
T_OUTTAB = IMARA.
ENDFORM. "write_report
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 = 'Status'.
FC_TMP-FIELDNAME = 'LIGHT'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '4'.
FC_TMP-ICON = 'X'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material Number'.
FC_TMP-FIELDNAME = 'MATNR'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '18'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material Type'.
FC_TMP-FIELDNAME = 'MTART'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '10'.
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-EMPHASIZE = 'C610'. " color column
APPEND FC_TMP TO FIELDCAT.
ENDFORM. "build_field_catalog
Thanks,
Shankar -
Internal table to define condition range
Hi
Can someone tell me what is the internal table where condition(BEx Analizer) variable range is defined
Thanks
SheetalHi,
Try out this link.....
Dynamic Where Clause
or u can try with the following......
sample code:
append 'loop at tab2 into wa2 ' to prog.
loop at formel."customize-table
concatenate 'wa1-' formel-feld1 into dbfeld.
if sy-tabix = 1.
concatenate 'where' formel-feld1 formel-operator dbfeld
into prog-line separated by space.
else.
concatenate 'and' formel-feld1 formel-operator dbfeld
into prog-line separated by space.
endif.
append prog.
data: lr_bukrs type range of bseg-bukrs, lr_gjahr type range of bseg-gjahr, lr_belnr type range of bseg-belnr.*** filll range(s) dynamically **** ...* ...loop at itab where bukrs in lr_bukrs and gjahr in lr_gjahr and belnr in lr_belnr.* do somethingendloop.
Because a where-condition on an empty range is always true, empty ranges will be ignored
and only the ranges with values will be used for comparison.
To fill a range, you may use
PERFORM append_range USING 'IEQ' '2006' '' CHANGING lr_gjahr.
using this universal reusable lightning-fast form
&----& Form append_range&--** append selection range*--
FORM append_range USING p_signopt TYPE c p_low TYPE any p_high TYPE any CHANGING pt_range TYPE table. FIELD-SYMBOLS: <range> TYPE ANY, <sign> TYPE ANY, <option> TYPE ANY, <low> TYPE ANY, <high> TYPE ANY. DATA: l_ref TYPE REF TO data. CREATE DATA l_ref LIKE LINE OF pt_range. ASSIGN l_ref-> TO <range>. CHECK sy-subrc = 0. ASSIGN COMPONENT 'SIGN' OF STRUCTURE <range> TO <sign>. CHECK sy-subrc = 0. ASSIGN COMPONENT 'OPTION' OF STRUCTURE <range> TO <option>. CHECK sy-subrc = 0. ASSIGN COMPONENT 'LOW' OF STRUCTURE <range> TO <low>. CHECK sy-subrc = 0. ASSIGN COMPONENT 'HIGH' OF STRUCTURE <range> TO <high>. CHECK sy-subrc = 0. <sign> = p_signopt(1). <option> = p_signopt+1(2). <low> = p_low. <high> = p_high. READ TABLE pt_range WITH KEY table_line = <range> TRANSPORTING NO FIELDS BINARY SEARCH. CHECK sy-subrc <> 0. INSERT <range> INTO pt_range INDEX sy-tabix..ENDFORM. " append_range
Warm Regards
Suma Humberi -
Internal table -Select statement -2nd plant is not being filled
Hi,
Second field for plant WERKD is not getting filled in this table.I am using into corresponding fields of table ITAB statement.
I need both plants and in single select statement.
Any ideas?
DATA: BEGIN OF T_STOF OCCURS 0,
VBELN LIKE LIPS-VBELN,
ERNAM LIKE LIPS-ERNAM,
WERKS LIKE LIPS-WERKS,
NTGEW LIKE LIPS-NTGEW,
GEWEI LIKE LIPS-GEWEI,
EBELN LIKE EKKO-EBELN,
WERKD LIKE EKPO-WERKS,
LGORT LIKE EKPO-LGORT,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
TXZ01 LIKE EKPO-TXZ01,
AEDAT LIKE EKPO-AEDAT,
KNUMV LIKE EKKO-KNUMV,
END OF T_STOF.
SELECT LIKPVBELN LIKPERNAM LIPSWERKS LIPSNTGEW LIPS~GEWEI
EKKOEBELN EKPOWERKS EKPOLGORT EKPOEBELP EKPOMATNR EKPOTXZ01 EKPOAEDAT EKKOKNUMV
INTO CORRESPONDING FIELDS OF TABLE T_STOF
FROM LIKP
INNER JOIN LIPS
ON LIKPVBELN EQ LIPSVBELN
INNER JOIN EKKO
ON LIPSVGBEL EQ EKKOEBELN
INNER JOIN EKPO
ON EKKOEBELN EQ EKPOEBELN
WHERE LIKP~VBELN IN S_VBELN
AND LIKP~ERNAM IN S_ERNAM
AND LIPS~WERKS IN S_WERKS
AND EKKO~EBELN IN S_EBELN
AND EKPO~WERKS IN S_WERKD
AND EKPO~LGORT IN S_LGORT
AND EKPO~MATNR IN S_MATNR
AND EKPO~AEDAT IN S_AEDAT
AND BSART = 'UB'.
Or am i doing in wrong?
Regards
PraveenHi,
If you use INTO CORRESPONDING then the fieldname in the internal table has to match the selecting field name..
To avoid this you can use INTO TABLE...
SELECT LIKPVBELN LIKPERNAM LIPSWERKS LIPSNTGEW LIPS~GEWEI
EKKOEBELN EKPOWERKS EKPOLGORT EKPOEBELP EKPOMATNR EKPOTXZ01 EKPOAEDAT EKKOKNUMV
<b>INTO TABLE T_STOF</b>
Thanks,
Naren -
Hi Experts,
I have one internal table with some values like
PLNNR PLNAL ZAEHL
5000021 01 01
5000021 01 02
5000021 01 03
5000021 01 04
5000021 01 05
I want to fetch greatest value from ZAEHL column.
Can any one pls help me.
Thanks,
Madhu.Hi Gordan,
I am getting error like " itab is not defined in the ABAP Dictionary as a table , projection view or database view."
Can you pls guide me .
Thanks,
Kaladhar. -
Select query for picking data in a dynamic internal table
Dear All,
Please help.
<u>The code is :</u>
p_table1 = itab_final-tabname1.
p_field1 = itab_final-fieldname1.
SELECT (p_field1) FROM (p_table1) INTO CORRESPONDING FIELDS OF TABLE <dyntable1>.
It is working fine when the domain is of CHAR
The piece of code is not working where domain is DATS, CURR, DEC, etc.
What shall I do so that it works for other domains also. Please its urgent......
<u>ERROR that came:</u>
An exception occurred. This exception will be dealt with in more detail
below. The exception, assigned to the class 'CX_SY_OPEN_SQL_DB', was not
caught, which
led to a runtime error. The reason for this exception is:
The data read during a SELECT access could not be inserted into the
target field.
Either conversion is not supported for the target field's type or the
target field is too short to accept the value or the data are not in a
form that the target field can acceptCheck below code
REPORT zpwtest .
*** Tables
DATA: lt_data TYPE REF TO data.
DATA: lt_fieldcatalog TYPE lvc_t_fcat.
data : p_field type string ,
p_table type string .
*** Structure
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
*** Data References
DATA: new_line TYPE REF TO data.
*** Field Symbols
FIELD-SYMBOLS: <fs_data> TYPE REF TO data,
<fs_1> TYPE ANY TABLE,
<fs_2>,
<fs_3>.
ls_fieldcatalog-fieldname = 'MANDT'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
ls_fieldcatalog-inttype = 'C'. "Internal Type C-> Character
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CONNID'.
ls_fieldcatalog-inttype = 'N'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'FLDATE'.
ls_fieldcatalog-inttype = 'D'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'PRICE'.
ls_fieldcatalog-inttype = 'P'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CURRENCY'.
ls_fieldcatalog-inttype = 'C'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fieldcatalog
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2
IF sy-subrc <> 0.
ENDIF.
*** So <FS_1> now points to our dynamic internal table.
ASSIGN <fs_data>->* TO <fs_1>.
*** Next step is to create a work area for our dynamic internal table.
CREATE DATA new_line LIKE LINE OF <fs_1>.
*** A field-symbol to access that work area
ASSIGN new_line->* TO <fs_2>.
<b>
p_field = 'mandt carrid connid fldate price currency' .
p_table = 'sflight' .
*** And to put the data in the internal table
SELECT (p_field)
FROM (p_table)
INTO CORRESPONDING FIELDS OF TABLE <fs_1>.
</b>
*** Access contents of internal table
LOOP AT <fs_1> ASSIGNING <fs_2>.
ASSIGN COMPONENT 5 OF STRUCTURE <fs_2> TO <fs_3>.
WRITE: / <fs_3>.
ENDLOOP. -
Usage of 'Select for all entries' for dynamic internal tables..
Hi all,
I have a situation where I need to use select for all entries for a dynamic internal table.
select * from /BIC/AZHSD_O1500 into i_table for all entries in <b>Dynamic_table</b> where doc_number = <dynamic_table????????>
here iam not knowing how to match the <dynamic_table????????> doc_number ?
the dynamic_table contains the doc_number as one field.
here dynaimc_table is the internal table which is dynamic.
I have tried various options but couldnot find the solution.
Please resolve.
Sidhartha.data : i_dyn_where type char72 occurs 0.
field-symbols : <fs> type table.
assign itab[] to <fs>.
i_dyn_where = 'docno = <fs>-docno'.
append i_dyn_where.
select *
from vbak
into table t_vbak
for all entries in <fs>
where (I_dyn_where). "Populate this where condition dynamically too
Hope this will solve ur prob. -
Hi
I have a requirement of writing internal table data to XML. Any idea where i should start.
I have pretty good experience with ABAP and basic knowledge in XML.
There are good blogs which talk about transformations and other stuff but they are not able to give me clear path to my solution.
Could somebody give me a basic example or some reference material where i can move the data in internal table (assume Sales order details of a day) to XML.
ThanksRefer the program -
In this implementation we will only focus on the creation of the XML file and the transfer to the user. You can not create a XML document directly. You have to use a so called ixml factory first.
TYPE-POOLS: ixml.
DATA: l_ixml TYPE REF TO if_ixml.
l_ixml = cl_ixml=>create( ).
This iXML factory can create an empty XML document object named l_document.
DATA: l_document TYPE REF TO if_ixml_document.
l_document = l_ixml->create_document( ).
At this point you can add the nodes (elements, attributes) into the document. First you have to declare the root element node.
DATA: l_element_root TYPE REF TO if_ixml_element.
This node we have to give a name and add it (create_simple_node) to the document object l_document, which will be the parent of this node.
l_element_root = l_document->create_simple_element(
name = 'flights'
parent = l_document ).
Next we can add child nodes to there parent node using the same method of the document object.
DATA: l_element_airline TYPE REF TO if_ixml_element,
l_element_airline = l_document->create_simple_element(
name = 'airline'
parent = l_element_root ).
An attribute can be add easily using the method set_attribute of the element node.
l_rc = l_element_airline->set_attribute( name = 'code' value = 'LH401' ).
Now we have finished the document object. Regretfully it can not be displayed in any form due to the fact that it is a binary object.
The next step is to convert the created document to a flat file. To achieve this we have to create a stream factory, which will help us to create an output stream.
DATA: l_streamfactory TYPE REF TO if_ixml_stream_factory.
l_streamfactory = l_ixml->create_stream_factory( ).
In this case, we will convert the document into an output stream which is based on an internal table of type x.
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: l_xml_table TYPE TABLE OF xml_line,
l_xml_size TYPE i,
l_rc TYPE i,
l_ostream TYPE REF TO if_ixml_ostream.
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
When we have created the output stream we can do the rendering from the document into the stream. The XML data will be stored in the internal table automatically.
DATA: l_renderer TYPE REF TO if_ixml_renderer.
l_renderer = l_ixml->create_renderer( ostream = l_ostream
& nbsp; document = l_document ).
l_rc = l_renderer->render( ).
In the last step we upload the file to the sapgui
l_xml_size = l_ostream->get_num_written_raw( ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = 'c:\temp\flights.xml'
filetype = 'BIN'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
This finished the first step-of-three. As mentioned before the next log will focus on the conversion from xml files (back) to abap tables.
REPORT z_xit_xml_dom_create.
TYPE-POOLS: ixml.
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_ostream TYPE REF TO if_ixml_ostream,
l_renderer TYPE REF TO if_ixml_renderer,
l_document TYPE REF TO if_ixml_document.
DATA: l_element_flights TYPE REF TO if_ixml_element,
l_element_airline TYPE REF TO if_ixml_element,
l_element_flight TYPE REF TO if_ixml_element,
l_element_from TYPE REF TO if_ixml_element,
l_element_to TYPE REF TO if_ixml_element,
l_element_dummy TYPE REF TO if_ixml_element,
l_value TYPE string.
DATA: l_xml_table TYPE TABLE OF xml_line,
l_xml_size TYPE i,
l_rc TYPE i.
DATA: lt_spfli TYPE TABLE OF spfli.
DATA: l_spfli TYPE spfli.
START-OF-SELECTION.
Fill the internal table
SELECT * FROM spfli INTO TABLE lt_spfli.
Sort internal table
SORT lt_spfli BY carrid.
Start filling xml dom object from internal table
LOOP AT lt_spfli INTO l_spfli.
AT FIRST.
Creating a ixml factory
l_ixml = cl_ixml=>create( ).
Creating the dom object model
l_document = l_ixml->create_document( ).
Fill root node with value flights
l_element_flights = l_document->create_simple_element(
name = 'flights'
parent = l_document ).
ENDAT.
AT NEW carrid.
Create element 'airline' as child of 'flights'
l_element_airline = l_document->create_simple_element(
name = 'airline'
parent = l_element_flights ).
Create attribute 'code' of node 'airline'
l_value = l_spfli-carrid.
l_rc = l_element_airline->set_attribute( name = 'code' value = l_value ).
Create attribute 'name' of node 'airline'
SELECT SINGLE carrname FROM scarr INTO l_value WHERE carrid EQ l_spfli-carrid.
l_rc = l_element_airline->set_attribute( name = 'name' value = l_value ).
ENDAT.
AT NEW connid.
Create element 'flight' as child of 'airline'
l_element_flight = l_document->create_simple_element(
name = 'flight'
parent = l_element_airline ).
Create attribute 'number' of node 'flight'
l_value = l_spfli-connid.
l_rc = l_element_flight->set_attribute( name = 'number' value = l_value ).
ENDAT.
Create element 'from' as child of 'flight'
CONCATENATE l_spfli-cityfrom ',' l_spfli-countryfr INTO l_value.
l_element_from = l_document->create_simple_element(
name = 'from'
value = l_value
parent = l_element_flight ).
Create attribute 'airport' of node 'from'
l_value = l_spfli-airpfrom.
l_rc = l_element_from->set_attribute( name = 'airport' value = l_value ).
Create element 'to' as child of 'flight'
CONCATENATE l_spfli-cityto ',' l_spfli-countryto INTO l_value.
l_element_to = l_document->create_simple_element(
name = 'to'
value = l_value
parent = l_element_flight ).
Create attribute 'airport' of node 'from'
l_value = l_spfli-airpto.
l_rc = l_element_to->set_attribute( name = 'airport' value = l_value ).
Create element 'departure' as child of 'flight'
l_value = l_spfli-deptime.
l_element_dummy = l_document->create_simple_element(
name = 'departure'
value = l_value
parent = l_element_flight ).
Create element 'arrival' as child of 'flight'
l_value = l_spfli-arrtime.
l_element_dummy = l_document->create_simple_element(
name = 'arrival'
value = l_value
parent = l_element_flight ).
Create element 'type' as child of 'flight'
CASE l_spfli-fltype.
WHEN 'X'.
l_value = 'Charter'.
WHEN OTHERS.
l_value = 'Scheduled'.
ENDCASE.
l_element_dummy = l_document->create_simple_element(
name = 'type'
value = l_value
parent = l_element_flight ).
ENDLOOP.
IF sy-subrc NE 0.
MESSAGE 'No data into db table ''spfli'', please run program ''SAPBC_DATA_GENERATOR'' with transaction ''SA38''' TYPE 'E'.
ENDIF.
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
Connect internal XML table to stream factory
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
Rendering the document
l_renderer = l_ixml->create_renderer( ostream = l_ostream
document = l_document ).
l_rc = l_renderer->render( ).
Saving the XML document
l_xml_size = l_ostream->get_num_written_raw( ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = 'c:\temp\flights.xml'
filetype = 'BIN'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
<?xml version="1.0"?>
<flights>
<airline code="AA" name="American Airlines">
<flight number="0017">
<from airport="JFK">NEW YORK,US</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>110000</departure>
<arrival>140100</arrival>
<type>Scheduled</type>
</flight>
<flight number="0064">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="JFK">NEW YORK,US</to>
<departure>090000</departure>
<arrival>172100</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="AZ" name="Alitalia">
<flight number="0555">
<from airport="FCO">ROME,IT</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>190000</departure>
<arrival>210500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0788">
<from airport="FCO">ROME,IT</from>
<to airport="TYO">TOKYO,JP</to>
<departure>120000</departure>
<arrival>085500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0789">
<from airport="TYO">TOKYO,JP</from>
<to airport="FCO">ROME,IT</to>
<departure>114500</departure>
<arrival>192500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0790">
<from airport="FCO">ROME,IT</from>
<to airport="KIX">OSAKA,JP</to>
<departure>103500</departure>
<arrival>081000</arrival>
<type>Charter</type>
</flight>
</airline>
<airline code="DL" name="Delta Airlines">
<flight number="1984">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="JFK">NEW YORK,US</to>
<departure>100000</departure>
<arrival>182500</arrival>
<type>Scheduled</type>
</flight>
<flight number="1699">
<from airport="JFK">NEW YORK,US</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>171500</departure>
<arrival>203700</arrival>
<type>Scheduled</type>
</flight>
<flight number="0106">
<from airport="JFK">NEW YORK,US</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>193500</departure>
<arrival>093000</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="JL" name="Japan Airlines">
<flight number="0407">
<from airport="NRT">TOKYO,JP</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>133000</departure>
<arrival>173500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0408">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="NRT">TOKYO,JP</to>
<departure>202500</departure>
<arrival>154000</arrival>
<type>Charter</type>
</flight>
</airline>
<airline code="LH" name="Lufthansa">
<flight number="2407">
<from airport="TXL">BERLIN,DE</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>071000</departure>
<arrival>081500</arrival>
<type>Scheduled</type>
</flight>
<flight number="2402">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="SXF">BERLIN,DE</to>
<departure>103000</departure>
<arrival>113500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0402">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="JFK">NEW YORK,US</to>
<departure>133000</departure>
<arrival>150500</arrival>
<type>Charter</type>
</flight>
<flight number="0401">
<from airport="JFK">NEW YORK,US</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>183000</departure>
<arrival>074500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0400">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="JFK">NEW YORK,US</to>
<departure>101000</departure>
<arrival>113400</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="QF" name="Qantas Airways">
<flight number="0005">
<from airport="SIN">SINGAPORE,SG</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>225000</departure>
<arrival>053500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0006">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="SIN">SINGAPORE,SG</to>
<departure>205500</departure>
<arrival>150500</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="SQ" name="Singapore Airlines">
<flight number="0988">
<from airport="SIN">SINGAPORE,SG</from>
<to airport="TYO">TOKYO,JP</to>
<departure>163500</departure>
<arrival>001500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0158">
<from airport="SIN">SINGAPORE,SG</from>
<to airport="JKT">JAKARTA,ID</to>
<departure>152500</departure>
<arrival>160000</arrival>
<type>Scheduled</type>
</flight>
<flight number="0015">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="SIN">SINGAPORE,SG</to>
<departure>160000</departure>
<arrival>024500</arrival>
<type>Scheduled</type>
</flight>
<flight number="0002">
<from airport="SIN">SINGAPORE,SG</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>170000</departure>
<arrival>192500</arrival>
<type>Scheduled</type>
</flight>
</airline>
<airline code="UA" name="United Airlines">
<flight number="0941">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>143000</departure>
<arrival>170600</arrival>
<type>Scheduled</type>
</flight>
<flight number="3504">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>150000</departure>
<arrival>103000</arrival>
<type>Scheduled</type>
</flight>
<flight number="3516">
<from airport="JFK">NEW YORK,US</from>
<to airport="FRA">FRANKFURT,DE</to>
<departure>162000</departure>
<arrival>054500</arrival>
<type>Scheduled</type>
</flight>
<flight number="3517">
<from airport="FRA">FRANKFURT,DE</from>
<to airport="JFK">NEW YORK,US</to>
<departure>104000</departure>
<arrival>125500</arrival>
<type>Scheduled</type>
</flight>
</airline>
</flights>
Regards,
Amit
Reward all helpful replies. -
Combine 2 internal tables into a single internal table
Hi
I need to replace the following join statement by splitting it into 2 select statements and then combine them into a single internal table
SELECT vbak~waerk
vbapvbeln vbapposnr vbapnetwr vbapbrgew
vbap~erdat "IM152805
INTO CORRESPONDING FIELDS OF TABLE l_t_orders
FROM vbak INNER JOIN vbap ON vbakvbeln = vbapvbeln
FOR ALL entries IN t_mchb
WHERE vbap~vbeln = t_mchb-vbeln
AND vbap~posnr = t_mchb-posnr.
Need to replace the above with separate select statements and then combine the result into a single internal table...
could anyone please help me...
thanks in advanceHi,
Check the code below,
select vbeln waerk
from vbak into table it_vbak for all entries in t_mchb where vbeln = t_mchb-vbeln.
select posnr
netwr
brgew
erdat "IM152805
INTO TABLE it_vbap
for all entries in t_mchb
where vbeln = t_mchb-vbeln
and posnr = t_mchb-posnr.
loop at it_vbap into wa_vbap.
read table it_vbak into wa_vbak where vbeln = wa_vbap-vbeln.
if sy-subrc = 0.
l_t_orders-waerk = wa_vbak-waerk.
l_t_orders-vbeln = wa_vbap-vbeln.
l_t_orders-posnr = wa_vbap-posnr
l_t_orders-netwr = wa_vbap-netwr.
l_t_orders-brgew = wa_vbap-brgew.
l_t_orders-erdat = wa_vbap-erdat.
append l_t_orders.
endif.
endloop.
Reward if it is helpful.
Regards,
Bhanu -
Delete lines from internal table
Hello experts!
I have two internal tables.
select options sa_tknr and gt_versand_plan.
sa_tknr-low contents transportation-Nr.
gt_versand_plan has transportation-Nr too (gt_versand_plan-tknum).
How can I delete all transportation-Nr from
gt_versand_plan which dont' appear in sa_tknr-tknum.
THX
sasHi
check this statement.
<b>delete gt_versand_plan where not tknum in sa_tknr.</b>
<b>Reward points for useful Answers</b>
Regards
Anji -
Internal table with and with out work area.
Hi all,
in performance terms which one is better 1) internal table with header line or 2) itab w/o header line and explicit work area for that itab.
which one is better and how?
Thanks in advance.
SAIHai Sai Ram
Internal Table with header Line Improves the Performence
1)
TABLES CUSTOMERS.
Defining an internal table with header line
DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100
WITH HEADER LINE.
Reading all entries of the database table into the internal table
SELECT * FROM CUSTOMERS INTO TABLE ALL_CUSTOMERS.
2)
Check the following code for the Difference
REPORT ZWRITEDOC LINE-SIZE 124 NO STANDARD PAGE HEADING.
TABLES: DD03L, "
DD04T, "R/3-DD: Textos de los elementos de datos
DD02T. "R/3-DD: Textos de tablas SAP
Tabla temporal con las lineas de cada tabla
DATA: BEGIN OF I_LINEAS OCCURS 100,
LINEA(80),
END OF I_LINEAS.
Tabla con las caracteristicas de la tabla
DATA: BEGIN OF I_TABLA OCCURS 100,
CAMPO(12),
TIPO(4),
LONG(5) TYPE I,
REF(20),
DESCR(40),
END OF I_TABLA.
DATA: D_NOMBRE(80),
D_DESCRIPCION(80).
DATA : BEGIN OF SOURCE OCCURS 1000,
LINE(72),
END OF SOURCE.
PARAMETERS: PROGRAM LIKE SY-REPID DEFAULT SY-REPID.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'GRAB'.
PERFORM GRABAR.
ENDCASE.
START-OF-SELECTION.
SET PF-STATUS 'ZSTATUS1'.
READ REPORT PROGRAM INTO SOURCE.
DATA L_GRAB.
CLEAR L_GRAB.
LOOP AT SOURCE.
translate source to upper case.
IF L_GRAB IS INITIAL.
D_DESCRIPCION = I_LINEAS-LINEA.
ENDIF.
I_LINEAS = SOURCE.
SEARCH I_LINEAS-LINEA FOR 'BEGIN OF'.
IF SY-SUBRC = 0.
SEARCH I_LINEAS-LINEA FOR 'DATA'.
IF SY-SUBRC = 0.
L_GRAB = 'X'.
FREE I_LINEAS.
ENDIF.
ENDIF.
IF L_GRAB = 'X'.
I_LINEAS = SOURCE.
APPEND I_LINEAS.
SEARCH I_LINEAS-LINEA FOR 'END OF'.
IF SY-SUBRC = 0.
CLEAR L_GRAB.
PERFORM PROCESAR_FICHERO.
PERFORM IMPRIMIR.
FREE I_LINEAS.
CLEAR D_DESCRIPCION.
ENDIF.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'WITH HEADER LINE'.
IF SY-SUBRC = 0.
APPEND I_LINEAS.
PERFORM PROCESAR_FICHERO.
PERFORM IMPRIMIR.
ENDIF.
ENDLOOP.
*& Form GRABAR
Graba el fichero en c:\temp\p.rtf y lo abre con word.
FORM GRABAR.
CALL FUNCTION 'LIST_DOWNLOAD'
EXPORTING
LIST_INDEX = SLIST_INDEX_DEFAULT
METHOD = 'RTF'
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'EXECUTE_WINWORD'
EXPORTING
I_FILE = 'C:\TEMP\P.RTF'
EXCEPTIONS
OTHERS = 1.
ENDFORM. " GRABAR
*& Form PROCESAR_FICHERO
FORM PROCESAR_FICHERO.
DATA: L_AUX1(80),
L_AUX2(80).
FREE I_TABLA.
LOOP AT I_LINEAS.
CLEAR I_TABLA.
translate i_lineas-linea to upper case.
SEARCH I_LINEAS-LINEA FOR 'BEGIN OF'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT 'BEGIN OF' INTO L_AUX1 D_NOMBRE.
SPLIT D_NOMBRE AT 'OCCURS' INTO D_NOMBRE L_AUX1.
ENDIF.
SEARCH I_LINEAS-LINEA FOR '('.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT '(' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
I_TABLA-CAMPO = L_AUX1.
SPLIT L_AUX2 AT ')' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
IF L_AUX1 CO '0123456789 '.
I_TABLA-LONG = L_AUX1.
ENDIF.
I_TABLA-TIPO = 'CHAR'.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'LIKE'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT 'LIKE' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
I_TABLA-CAMPO = L_AUX1.
SPLIT L_AUX2 AT ',' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
I_TABLA-REF = L_AUX1.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'TYPE'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT 'TYPE' INTO L_AUX1 L_AUX2.
IF I_TABLA-CAMPO IS INITIAL.
CONDENSE L_AUX1.
I_TABLA-CAMPO = L_AUX1.
ENDIF.
SPLIT L_AUX2 AT ',' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
CASE L_AUX1.
WHEN 'I'.
I_TABLA-TIPO = 'INT'.
I_TABLA-LONG = 4.
WHEN 'C'.
I_TABLA-TIPO = 'CHAR'.
WHEN 'N'.
I_TABLA-TIPO = 'NUMC'.
WHEN 'T'.
I_TABLA-TIPO = 'TIME'.
I_TABLA-LONG = 8.
WHEN OTHERS.
I_TABLA-TIPO = L_AUX1.
ENDCASE.
ENDIF.
SEARCH I_LINEAS-LINEA FOR '"'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT '"' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX2.
I_TABLA-DESCR = L_AUX2.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'INCLUDE STRUCTURE'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT 'INCLUDE STRUCTURE' INTO L_AUX1 L_AUX2.
SPLIT L_AUX2 AT '.' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
I_TABLA-CAMPO = 'INCLUDE STR'.
I_TABLA-REF = L_AUX1.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'WITH HEADER LINE'.
IF SY-SUBRC = 0.
IF NOT I_LINEAS-LINEA CA '"'.
SPLIT I_LINEAS-LINEA AT 'OCCURS' INTO L_AUX1 L_AUX2.
IF SY-SUBRC = 0.
SPLIT L_AUX1 AT 'LIKE' INTO L_AUX1 L_AUX2.
IF SY-SUBRC = 0.
CONDENSE L_AUX2.
IF NOT L_AUX2 IS INITIAL.
I_TABLA-CAMPO = '...'.
I_TABLA-TIPO = 'TABI'.
I_TABLA-REF = L_AUX2.
SELECT SINGLE * FROM DD02T
WHERE TABNAME = L_AUX2
AND DDLANGUAGE = SY-LANGU.
IF SY-SUBRC = 0.
I_TABLA-TIPO = 'TABE'.
I_TABLA-DESCR = DD02T-DDTEXT.
ENDIF.
IF L_AUX1 CA ':'.
SPLIT L_AUX1 AT 'DATA:' INTO L_AUX1 L_AUX2.
ELSE.
SPLIT L_AUX1 AT 'DATA' INTO L_AUX1 L_AUX2.
ENDIF.
D_NOMBRE = L_AUX2.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
IF NOT I_TABLA-CAMPO IS INITIAL.
APPEND I_TABLA.
ENDIF.
ENDLOOP.
LOOP AT I_TABLA WHERE NOT REF IS INITIAL.
SPLIT I_TABLA-REF AT '-' INTO L_AUX1 L_AUX2.
SELECT SINGLE * FROM DD03L
WHERE TABNAME = L_AUX1
AND FIELDNAME = L_AUX2.
IF SY-SUBRC = 0.
I_TABLA-TIPO = DD03L-DATATYPE.
I_TABLA-LONG = DD03L-INTLEN.
IF I_TABLA-DESCR IS INITIAL.
SELECT SINGLE * FROM DD04T
WHERE ROLLNAME = DD03L-ROLLNAME
AND DDLANGUAGE = SY-LANGU.
IF SY-SUBRC = 0.
I_TABLA-DESCR = DD04T-DDTEXT.
ENDIF.
ENDIF.
MODIFY I_TABLA.
ENDIF.
ENDLOOP.
ENDFORM. " PROCESAR_FICHERO
*& Form IMPRIMIR
FORM IMPRIMIR.
DATA L_AUX(80).
FORMAT COLOR COL_NORMAL INTENSIFIED ON.
ULINE AT 1(80).
WRITE: / SY-VLINE,
(76) D_NOMBRE CENTERED,
SY-VLINE.
SPLIT D_DESCRIPCION AT '*' INTO L_AUX D_DESCRIPCION.
WRITE: / SY-VLINE,
(76) D_DESCRIPCION CENTERED,
SY-VLINE.
NEW-LINE.
ULINE AT 1(80).
DETAIL.
FORMAT COLOR OFF.
WRITE: /
SY-VLINE,
(10) 'CAMPO',
SY-VLINE,
(4) 'TIPO',
SY-VLINE,
(4) 'LONG',
SY-VLINE,
(16) 'REFERENCIA',
SY-VLINE,
(30) 'DESCRIPCION',
SY-VLINE.
NEW-LINE.
ULINE AT 1(80).
DETAIL.
LOOP AT I_TABLA.
WRITE: /
SY-VLINE,
(10) I_TABLA-CAMPO,
SY-VLINE,
I_TABLA-TIPO,
SY-VLINE,
(4) I_TABLA-LONG,
SY-VLINE,
(16) I_TABLA-REF,
SY-VLINE,
(30) I_TABLA-DESCR,
SY-VLINE.
ENDLOOP.
NEW-LINE.
ULINE AT 1(80).
SKIP 2.
ENDFORM. " IMPRIMIR
Thanks & regards
Sreeni -
How to use dynamic internal table with FOR ALL ENTRIES
Hello SDNers,
I am having a dynamic internal table & want to use FOR ALL ENTRIES(FAE) using this dyn. table.
This works fine for me:
IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
SELECT field1 field2
FROM TABLE ztable
INTO TABLE itab "Itab is a static table
FOR ALL ENTRIES IN <lt_tmp>
WHERE (lv_dynwhere). "lv_dynwhere -> dynamic where clause
ENDIF.
SAP documentation says:
"The logical expression sql_cond of the WHERE condition can be comprised of several logical expressions using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one comparison with a column of the internal table itab that can be specified statically or dynamically. "
How do we specify the column of the internal table dynamically ? Can we do something like this:
IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
SELECT field1 field2
FROM TABLE
INTO TABLE itab "Itab is a static table
FOR ALL ENTRIES IN <lt_tmp>
WHERE key_field1 = (dynamic token for column1 of <lt_tmp>)
key_field2 = (dynamic token for column2 of <lt_tmp>)
ENDIF.
ENDIF.
Let me know if i am not clear about my requirement.
BR,
SuhasHello Thomas,
What i meant was something like this:
WHERE key_field1 = ('<LT_TMP-COL1>') AND
key_field2 = ('<LT_TMP-COL2>')
I am confused by what SAP means with "dynamic representation of internal table columns" in FAE ?
@Rob: I was referring to SAPNW 7.0 documentation & the phrase (release 6.40 & higher) is missing. Anyways fyi i am on ECC5.0 ABAP release 6.40.
@Subhankar: This is what Marcin had proposed in For all entries and dynamic table.
Thanks,
Suhas
Edited by: Suhas Saha on Apr 6, 2010 11:53 AM -
[Function] Declare a internal table with structure name (entry parameter)
Hi all,
I'm explaining my problem :
I want to create a function with two parameters in entry :
(IMPORT) - structure_name with type DD02L-TABNAME
(TABLES) - t_outtab with empty type
t_outtab will be in structure_name type.
Now, in my source function, I want to retrieve all contain of t_outtab in another internal table or field-symbol. I don't know in advance the used structures in my function entries.
I don't manage to get this contain, cause I can't do :
DATA : internal_table TYPE structure_name*
OR
DATA : internal_table TYPE (structure_name)
OR used field-symbol
DATA : internal_table TYPE <fs>* where <fs> had structure name value.
To do more later :
*DATA : line LIKE LINE OF internal_table. *
*internal_table][ = t_outtab][. *
And work with this table.
_ I tried different solutions like : _
Get the structure of the table.
ref_table_des ?= cl_abap_typedescr=>describe_by_name( I_STRUCTURE_NAME ).
idetails[] = ref_table_des->components[].
Get the first structure table of result table
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.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
and retrieve to <dyn_table>[] = t_outtab[].
the but I don't try the solution. If someone have an idea.
Thanks and regards.
Romain
Edited by: Romain L on May 14, 2009 11:35 AMHi,
We can acheive this using dynamic internal tables.
Please find sample below.
*Creating Dynamic internal table
PARAMETERS : p_table(10) TYPE C.
DATA: w_tabname TYPE w_tabname,
w_dref TYPE REF TO data,
w_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
* Populating Dynamic internal table
SELECT *
FROM (w_tabname) UP TO 20 ROWS
INTO TABLE <t_itab>.
* Displaying dynamic internal table using Grid.
CREATE OBJECT w_grid
EXPORTING i_parent = cl_gui_container=>screen0.
CALL METHOD w_grid->set_table_for_first_display
EXPORTING
i_structure_name = w_tabname
CHANGING
it_outtab = <t_itab>.
CALL SCREEN 100.
* Scenario 2:
*Create a dynamic internal table with the specified number of columns.
* Creating Dynamic internal table
TYPE-POOLS: slis.
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE, u201C Dynamic internal table name
<fs_dyntable>, u201C Field symbol to create work area
<fs_fldval> type any. u201C Field symbol to assign values
PARAMETERS: p_cols(5) TYPE c. u201C Input number of columns
DATA: t_newtable TYPE REF TO data,
t_newline TYPE REF TO data,
t_fldcat TYPE slis_t_fldcat_alv,
t_fldcat TYPE lvc_t_fcat,
wa_it_fldcat TYPE lvc_s_fcat,
wa_colno(2) TYPE n,
wa_flname(5) TYPE c.
* Create fields .
DO p_cols TIMES.
CLEAR wa_it_fldcat.
move sy-index to wa_colno.
concatenate 'COL'
wa_colno
into wa_flname.
wa_it_fldcat-fieldname = wa_flname.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 10.
APPEND wa_it_fldcat TO t_fldcat.
ENDDO.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fldcat
IMPORTING
ep_table = t_newtable.
ASSIGN t_newtable->* TO <t_dyntable>.
* Create dynamic work area and assign to FS
CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
ASSIGN t_newline->* TO <fs_dyntable>.
*Populating Dynamic internal table
DATA: fieldname(20) TYPE c.
DATA: fieldvalue(10) TYPE c.
DATA: index(3) TYPE c.
DO p_cols TIMES.
index = sy-index.
MOVE sy-index TO wa_colno.
CONCATENATE 'COL'
wa_colno
INTO wa_flname.
* Set up fieldvalue
CONCATENATE 'VALUE' index INTO
fieldvalue.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
ENDDO.
* Append to the dynamic internal table
APPEND <fs_dyntable> TO <t_dyntable>.
* Displaying dynamic internal table using Grid.
DATA: wa_cat LIKE LINE OF fs_fldcat.
DO p_cols TIMES.
CLEAR wa_cat.
MOVE sy-index TO wa_colno.
CONCATENATE 'COL'
wa_colno
INTO wa_flname.
wa_cat-fieldname = wa_flname.
wa_cat-seltext_s = wa_flname.
wa_cat-outputlen = '10'.
APPEND wa_cat TO fs_fldcat.
ENDDO.
* Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = fs_fldcat
TABLES
t_outtab = <t_dyntable>.
Thanks,
Jyothi
Edited by: Jyothi on May 14, 2009 11:42 AM
Edited by: Jyothi on May 14, 2009 11:43 AM -
Dear experts,
i need to put the below 4 internal table values into i_final internal table,
SELECT warpl wstra plnnr plnal
FROM mpos INTO CORRESPONDING FIELDS OF TABLE i_mpos
WHERE warpl IN p_warpl.
SELECT warpl abnum zaehl nplda terma stadt lrmdt
offze offzo abrud abrna
INTO CORRESPONDING FIELDS OF TABLE i_mhis
FROM mhis
FOR ALL ENTRIES IN i_mpos
where warpl = i_mpos-warpl.
SELECT plnnr plnal plnkn paket zaehl datuv strat
INTO CORRESPONDING FIELDS OF TABLE i_plwp
FROM plwp
FOR ALL ENTRIES IN i_mpos
WHERE plnnr = i_mpos-plnnr AND
plnal = i_mpos-plnal.
SELECT plnnr plnkn ltxa1 arbei
INTO CORRESPONDING FIELDS OF TABLE i_plpo
FROM plpo
FOR ALL ENTRIES IN i_plwp
WHERE plnnr = i_plwp-plnnr AND
plnkn = i_plwp-plnkn.
could any one pls send coding for the above
thanks in advance
karthikI cannot check fully because i dont have records for this combination. you can try this with your records.
I hope it will work.
REPORT Z_TESTYUVA .
Tables : MPOS,
MHIS,
PLWP,
PLPO.
*data p_warpl LIKE mpos-warpl.
Parameter : p_warpl LIKE mpos-warpl.
DATA : i_mpos LIKE mpos Occurs 0 With Header Line,
i_mhis LIKE mhis Occurs 0 With Header Line,
i_plwp LIKE plwp Occurs 0 With Header Line,
i_plpo LIKE plpo Occurs 0 With Header Line.
DATA : Begin of it_final Occurs 0 ,
warpl LIKE MPOS-warpl,
wstra LIKE MPOS-wstra,
plnnr LIKE MPOS-plnnr,
plnal LIKE MPOS-plnal,
abnum LIKE MHIS-abnum,
zaehl LIKE MHIS-zaehl,
nplda LIKE MHIS-nplda,
terma LIKE MHIS-terma,
stadt LIKE MHIS-stadt,
lrmdt LIKE MHIS-lrmdt,
offze LIKE MHIS-offze,
offzo LIKE MHIS-offzo,
abrud LIKE MHIS-abrud,
abrna LIKE MHIS-abrna,
plnkn LIKE PLWP-plnkn,
paket LIKE PLWP-paket,
datuv LIKE PLWP-datuv,
strat LIKE PLWP-strat,
ltxa1 LIKE PLPO-ltxa1,
arbei LIKE PLPO-arbei,
END OF it_final.
SELECT warpl wstra plnnr plnal
FROM mpos INTO CORRESPONDING FIELDS OF TABLE i_mpos
WHERE warpl = p_warpl.
SELECT warpl abnum zaehl nplda terma stadt lrmdt
offze offzo abrud abrna
INTO CORRESPONDING FIELDS OF TABLE i_mhis
FROM mhis
FOR ALL ENTRIES IN i_mpos
where warpl = i_mpos-warpl.
SELECT plnnr plnal plnkn paket zaehl datuv strat
INTO CORRESPONDING FIELDS OF TABLE i_plwp
FROM plwp
FOR ALL ENTRIES IN i_mpos
WHERE plnnr = i_mpos-plnnr AND
plnal = i_mpos-plnal.
SELECT plnnr plnkn ltxa1 arbei
INTO CORRESPONDING FIELDS OF TABLE i_plpo
FROM plpo
FOR ALL ENTRIES IN i_plwp
WHERE plnnr = i_plwp-plnnr AND
plnkn = i_plwp-plnkn.
loop at i_mpos.
move-corresponding i_mpos to it_final.
LOOP AT i_mhis WHERE warpl = i_mpos-warpl.
move-corresponding i_mhis to it_final.
APPEND it_final.
CLEAR it_final.
ENDLOOP.
LOOP AT i_plwp WHERE plnnr = i_mpos-plnnr AND
plnal = i_mpos-plnal.
move-corresponding i_plwp to it_final.
MODIFY it_final TRANSPORTING plnnr plnal plnkn paket zaehl datuv strat "You can try giving all to transporting
WHERE plnnr = i_mpos-plnnr AND
plnal = i_mpos-plnal.
LOOP AT i_plpo WHERE plnnr = i_plwp-plnnr AND
plnkn = i_plwp-plnkn.
move-corresponding i_plpo to it_final.
MODIFY it_final TRANSPORTING plnnr plnkn ltxa1 arbei "You can try giving all to transporting
WHERE plnnr = i_plwp-plnnr AND
plnal = i_plwp-plnal.
ENDLOOP.
ENDLOOP.
ENDLOOP.
BY
Yuvaram.
Reward if useful -
Dynamic internal table assignment.
I have few internal tables in my bsp application but at a time i need to show 1 internal table based on some criteria into tableview.
can anybody guide me how to do so, its really urgent
Thanx,
AbhijeetHi Abhijeet,
Just use field-symbols and ur problem will be solved.
Check out the following code:
<% Field-symbols <var> type any .
.......logic for internal table selection..
assign it2 to <var>.
%>
<htmlb:tableView id="tab1" table="<%=<var>%>">
</htmlb:tableView>
Hope it'll help u.
Thanks & Regards,
Ankur
Maybe you are looking for
-
Delete Template in Word for Mac
How do I delete a template in Word for Mac 2011?
-
Cfinput validation is not working
I have a CF8 cfform which contains several cfinput tags set to required. If I submit the form without fillign otu those fields, I do get the popup message displaying the error message(s) but when I click ok on that popup, it still submits the form.
-
MSSQL Polling Issue with SAO 10.1.3.5
Hi All, We have an BPEL Process which is polling MSSQL table and it was working fine and suddenly it stopped working and when we saw the domain logs we got error as ORABPEL-11624 DBActivationSpec Polling Exception. Query name: [GetEmailData], Descrip
-
Team, can you someone help me on External Task. I see Command, Working Directory and Arguments on External Task. Header 1 Header 2 Command java -jar jmxtools.jar runjob -job TestProject -project ABC -u dnadmin localhost:8090 Working Directory \opt\lo
-
i have a LG BX327 projector which i'm unable to connect to my macbook pro, i have the HDMI, i have the adaptor but still whenever i connect it gives me an error NO SIGNAL!!!