Extract dataset to internal table
Hello,
Is it possible to transfer data in an extract field group to an internal table in a loop and how?
Thx in advance,
Ali.
Simply Loop at extract and move corresponding values to internal table. Example
TABLES: spfli, sflight, sbook.
"define extract without their structure
FIELD-GROUPS: header,
travel_time,
flight_detail.
"define structure of each record in extract
INSERT: spfli-cityfrom spfli-cityto INTO header, "sort by cities
spfli-deptime spfli-arrtime INTO travel_time,
sflight-carrid sflight-connid sflight-price INTO flight_detail.
"output table to transfer data to
DATA it_out_spfli TYPE TABLE OF spfli WITH HEADER LINE.
START-OF-SELECTION.
GET spfli.
"fill records of extract with data
EXTRACT: header, travel_time.
GET sflight.
EXTRACT flight_detail.
END-OF-SELECTION.
"sort the extract by the key determined in header field group
SORT.
LOOP.
AT NEW spfli-cityfrom.
WRITE: /'Connections from:', spfli-cityfrom.
ENDAT.
"connection must have details, flight_detail record must be found after this one
AT travel_time WITH flight_detail.
WRITE: /30 spfli-cityto, spfli-deptime, spfli-arrtime.
"move data to your table
MOVE-CORRESPONDING spfli TO it_out_spfli.
ENDAT.
AT flight_detail. "if record of field-group fligth_detail reached
WRITE: sflight-carrid, sflight-connid, sflight-price.
"move data to your table
MOVE-CORRESPONDING sflight TO it_out_spfli.
ENDAT.
AT END OF spfli-cityfrom.
WRITE: /80'Total cities travel', cnt(spfli-cityto).
ULINE.
ENDAT.
APPEND it_out_spfli.
ENDLOOP.
You need also make sure that all fields in IT_OUT_SPFLI are correcly provided. In my example there are some gaps but this is just a matter of supplying rest of the fields.
Regards
Marcin
Similar Messages
-
Import from database an internal table with generic Type : Web Dynpro ABAP
Hi everyone,
i have a requirement in which i'm asked to transfer data flow between two frameworks, from WD Component to another. The problem is that i have to transfer internal tables with generic types. i used the import/ export from database approache but in that way i get an error message saying "Object references and data references not yet supported".
Here is my code to extract a generic internal table from memory.
DATA l_table_f4 TYPE TABLE OF REF TO data.
FIELD-SYMBOLS: <l_table_f4> TYPE STANDARD TABLE.
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
DATA: ls_indx TYPE indx.
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->fire_vh_search_action_evt( ).
ASSIGN l_table_f4 TO <l_table_f4>.
*-- Import table for Help F4
IMPORT l_table_f4 TO <l_table_f4> FROM DATABASE indx(v1) TO ls_indx ID 'table_help_f4_ID'.
The error message is desplayed when last instruction is executed " IMPORT l_table_f4...".
I saw another post facing the same problem but never solved "Generic Type for import Database".
Please can anyone help ?
Thanks & Kind regards.hi KIan,
go:
general type
TYPE : BEGIN OF ty_itab,
field1 TYPE ztab-field1,
field2 TYPE ztab-field2,
*your own fields here:
field TYPE i,
field(30) TYPE c,
END OF ty_itab.
work area
DATA : gw_itab TYPE ty_itab.
internal table
DATA : gt_itab TYPE TABLE OF ty_itab.
hope this helps
ec -
Hello Dear ABAP Ace's,
Please let me know if what are differences between Extract datasets, Internal Tables, & Field Groups????? And what are the similarities?? Also let me know the uses of extract datasets & Field groups???
Thanks in advance.
Regards.
FarooqHi,
There are two ways of processing large quantities of data in ABAP - either using internal tables or extract datasets.
An internal table is a dynamic sequential dataset in which all records have the same structure and a key. They are part of the ABAP type concept. You can access individual records in an internal table using either the index or the key.
Extracts are dynamic sequential datasets in which different lines can have different structures. Each ABAP program may currently only have a single extract dataset. You cannot access the individual records in an extract using key or index. Instead, you always process them using a loop.
Check these links :
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
http://www.geocities.com/SiliconValley/Grid/4858/sap/ABAPCode/Fieldgroups.htm
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
Regards
L Appana -
Extract a value of a fields from an internal table
hello everyone,
i need to extract a value of a fields from an internal table, the fields is in a postion "sy-tabix" that i know, so i need to pick this value without using a loop
thank you.Like this?
DATA: FIELD1 TYPE C,
FIELD2 TYPE C.
READ TABLE T_TAB INDEX 3.
FIELD1 = T_TAB-FIELD1.
FIELD2 = T_TAB-FIELD2.
Greetings,
Blag. -
How to check if all values from a dataset has come to an internal table
How to check if all values from a dataset has come to an internal table ?
Hi,
After OPEN DATASET statement check if sy-subrc = 0 if its success then proceed with split statement and save the dataset values into a internal table and while debugging the internal table you will find that whether all values get into internal table.
Checking sy-subrc after OPEN DATASET statement is must to fill up the values in the internal table.
For e.g.
OPEN DATASET p_inpfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
WRITE :/ 'No such input file' .
EXIT.
ELSE.
READ DATASET p_inpfile INTO loc_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
CLEAR loc2.
*Spliting fields in the file-
REPLACE ALL OCCURRENCES OF '#' IN wa_string WITH ' '.
SPLIT wa_string AT const INTO loc2-pernr
loc2-werks
loc2-persk
loc2-vdsk1.
Hope you get some idea.
Thanks,
Sakthi C -
How to Extract Data from the PDF file to an internal table.
HI friends,
How can i Extract data from a PDF file to an internal table....
Thanks in Advance
ShankarShankar,
Have a look at these threads:-
extracting the data from pdf file to internal table in abap
Adobe Form (data extraction error)
Chintan -
Write internal table to a file on application server using OPEN DATASET
I have logical file path and XLS file name. I want to write internal table to a XLS or CSV file on application sever. Please give example.
Hi
see this program
EXCEL SHET to INTERNAL table and then to APPLICATION server
*& Report ZSD_EXCEL_INT_APP
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop. -
How to extract data from info cube into an internal table using ABAP code
HI
Can Anyone plz suggest me
How to extract data from info cube into an internal table using ABAP code like BAPI's or function modules.
Thankx in advance
regds
AJAYHI Dinesh,
Thankq for ur reply
but i ahve already tried to use the function module.
When I try to Use the function module RSDRI_INFOPOV_READ
I get an information message "ERROR GENERATION TEST FRAME".
can U plz tell me what could be the problem
Bye
AJAY -
Saving .csv into internal table - using dataset (',' comes between data)
Hi experts,
I need to save .csv from application server to internal table.
i am using the below code.
gt_raw and gwa_raw are dxrawdata format.
OPEN DATASET gv_pfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
WRITE:/ 'FILE UPLOAD FAILED - ERROR NO. : ', sy-subrc.
EXIT.
ELSE.
DO.
READ DATASET gv_pfile INTO gwa_raw.
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND gwa_raw TO gt_raw.
CLEAR gwa_raw.
ENDIF.
ENDDO.
*--Close the Application server file (Mandatory).
CLOSE DATASET gv_pfile.
ENDIF.
DELETE DATASET gv_pfile.
LOOP AT gt_raw into gwa_raw.
IF SY-TABIX > 1.
SPLIT gwa_raw at ',' into gwa_cust-cust_code
gwa_cust-cust_name
gwa_cust-grp_name
APPEND gwa_cust TO gt_cust.
CLEAR: gwa_cust, gwa_raw.
ENDIF.
ENDLOOP.
My program works fine.
But when the gwa_cust-grp_name contains the value for eg. -> panasonic co., ltd.
it takes till panasonic co., only
and leaves ltd. as i am using SPLIT command.
is there any other way to do this.
plz help me to solve this issue.
thanks.Hi,
I notice you have marked the message as answered, but I just wanted to let you know there is a solution. The trick is to parse into an internal table and then to find and reassemble fields that were split because they contgain a comma. The ABAP program below is a commented example.
Rgds,
Mark
REPORT zcsv_parse.
DATA:
tokens TYPE i.
TYPES: BEGIN OF ty_result,
company TYPE char20,
compnr TYPE i,
city TYPE char30,
country TYPE char30,
END OF ty_result.
DATA:
gt_rawtab TYPE TABLE OF string,
gw_rawtab LIKE LINE OF gt_rawtab,
gt_result TYPE TABLE OF ty_result,
gw_result LIKE LINE OF gt_result,
gt_parse TYPE TABLE OF string,
gw_parse LIKE LINE OF gt_parse.
DEFINE %csvline.
gw_rawtab = &1.
append gw_rawtab to gt_rawtab.
END-OF-DEFINITION.
START-OF-SELECTION.
* Create CSV lines, some with a comma inside a token
%csvline '"CompanyOne NV",500,"Antwerp","Belgium"'.
%csvline '"CompanyTwo,Inc",600,"New York,NY","USA"'.
%csvline '"CompanyThree,Ltd",700,"Sydney,NSW","Australia"'.
* Parse the raw CSV
LOOP AT gt_rawtab INTO gw_rawtab.
REFRESH gt_parse.
SPLIT gw_rawtab AT ',' INTO TABLE gt_parse.
DESCRIBE TABLE gt_parse LINES tokens.
* If extra commas: token count higher than field count
IF tokens > 4.
PERFORM reassemble.
ENDIF.
* At this point each entry in GT_PARSE contains exactly
* one result field => build the result table
LOOP AT gt_parse INTO gw_parse.
* Strip quotes from text fields
REPLACE ALL OCCURRENCES OF '"' IN gw_parse WITH ''.
CASE sy-tabix.
WHEN 1. gw_result-company = gw_parse.
WHEN 2. gw_result-compnr = gw_parse.
WHEN 3. gw_result-city = gw_parse.
WHEN 4. gw_result-country = gw_parse.
ENDCASE.
ENDLOOP.
APPEND gw_result TO gt_result.
ENDLOOP.
* Show the formatted result
LOOP AT gt_result INTO gw_result.
WRITE: / gw_result-company, gw_result-compnr,
gw_result-city, gw_result-country.
ENDLOOP.
*& Form reassemble
* Merges tokens that were split because they contain a comma
FORM reassemble.
DATA: lastpos TYPE i,
lastchar TYPE c,
currtoken LIKE sy-tabix,
nexttoken LIKE sy-tabix,
gw_next LIKE gw_parse.
LOOP AT gt_parse INTO gw_parse.
lastpos = STRLEN( gw_parse ) - 1.
lastchar = gw_parse+lastpos(1).
* Token starts with quote but does not end with one =>
* must merge with the next token
IF gw_parse+0(1) = '"' AND lastchar <> '"'.
currtoken = sy-tabix.
nexttoken = sy-tabix + 1.
READ TABLE gt_parse INTO gw_next INDEX nexttoken.
CONCATENATE gw_parse gw_next INTO gw_parse SEPARATED BY ','.
MODIFY gt_parse FROM gw_parse INDEX currtoken.
DELETE gt_parse INDEX nexttoken.
ENDIF.
ENDLOOP.
ENDFORM. "reassemble -
Problem in the internal table of open dataset statement
Hi abapers,
I am using the open dataset command to download my file at application server into an internal table.
But some colums of the internal table are string since i do not want to truncate any of the long text present in the file.
The open dataset command does not allow the internal table to have string components.
Is there any workaround by which i can download all the text components of the file without truncating them .
Regards,
Adityatry to use field symbols:-
FORM download_file .
DATA: l_file TYPE rlgrap-filename,
l_line TYPE string.
DATA: v_excel_string(1000) TYPE c,
v_len TYPE i,
v_zover TYPE i .
FIELD-SYMBOLS: <f> TYPE ANY .
CLEAR wa_fin.
*--- Seting File path
CONCATENATE p_cfile v_file sy-datum INTO l_file.
*--- Open data set
OPEN DATASET l_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
LOOP AT it_down INTO wa_down.
CLEAR : v_excel_string, v_zover, v_len.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_down TO <f>.
IF sy-subrc <> 0.
EXIT. "exits do loop and process next record in itab
ENDIF.
DESCRIBE FIELD <f> LENGTH v_len IN CHARACTER MODE.
v_excel_string+v_zover(v_len) = <f> .
v_zover = v_zover + v_len .
ENDDO.
TRANSFER v_excel_string TO l_file.
CLEAR : v_excel_string,
wa_down ,
v_zover .
ENDLOOP.
*--- Close data set
CLOSE DATASET l_file.
IF sy-subrc = 0.
*--- Success Message
MESSAGE s000(000) WITH text-018.
ENDIF.
ELSE.
*--- Error unable to open file.
MESSAGE e000(000) WITH text-017.
ENDIF.
ENDFORM. " DOWNLOAD_FILE
Thanks ,
Ruchi Tiwari -
SAP query change the internal table extracted after a join instruction
Hi Gurus
I would like to know if it is possible to change the data in internal table after that the
join instruction has been executed .
I should have to delete some lines extracted if some conditions are satisfied.
Do you think that it is not possible and it is better to crete a program?
Thanks in advanceHI,
use select and end select.
select single msegbukrs msegwerks msegmatnr msegmenge msegaufnr msegsmbln msegbwart msegshkzg mseg~meins
afkorsnum afpoverid
maststlnr maststlal stpoidnrk stpomenge stpomeins stkobmeng
into (itab-mblnr,
itab-budat,
itab-bktxt,
itab-bukrs,
itab-werks,
itab-matnr,
itab-menge,
itab-aufnr,
itab-smbln,
itab-bwart,
itab-shkzg,
itab-meins,
itab-rsnum,
itab-verid,
itab-stlnr,
itab-stlal,
itab-matnr_r,
itab-bdmng,
itab-meins_r,
itab-bmeng)
from mkpf
inner join mseg on msegmblnr eq mkpfmblnr and mkpfmjahr eq msegmjahr
inner join mara on maramatnr eq msegmatnr
inner join afpo on afpoaufnr eq msegaufnr
inner join mast on mastmatnr eq msegmatnr and mastwerks eq msegwerks
inner join afko on afkoaufnr eq msegaufnr and afkostlal eq maststlal
inner join stko on stkostlnr eq maststlnr and stkostlal eq maststlal
inner join stpo on stpostlnr eq stkostlnr
inner join stas on stasstlnr eq maststlnr and stasstlal eq maststlal and stasstlkn eq stpostlkn
where mseg~werks in s_werks
and mseg~matnr in s_matnr
and mkpf~budat in s_budat
and mseg~aufnr in s_aufnr
and mseg~bwart eq '101'
and mast~stlan eq '1'
and stko~stlty eq 'M'
and stpo~stlty eq 'M'.
if condtion .
append: itab.
endif.
clear: itab.
endselect.
Edited by: ZAHID HAMEED on Oct 12, 2011 3:56 PM -
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 -
How to extract data into excel file from more than one internal table
Hi Guys
I want to extract the data from module pool screen.
In screen there are two internal tables
1. header
2. items.
I want to extract the data as same format looking in the screen.
With simple Download FM we cannot do this one, because in this we will display as continuous rows.
<b> But my requirement is saving as table with heading, date, header details</b>
Note that it is not the simple down load . Suggest me with example codingHi Guys,
I think it depends on which software you will use to see the result.
If U are using Excel, it's very easy to achieve it.
1. Define a structure as string, the lenth depend on your need.And use the structure to define a internal table, supposed is as A..
2. Concatenate the head data using some separator, for ex. a comma; and then add this into A.
3. The above step's concatenate is depend on your format for request;For ex, you want to place the date at the 4th cell in excel, that means you should put three separator before the date field.
4 Concatenate the item data into the download table.
5. Download the table to file.
6. Display the file, using your defined separator.
Hope this helpful.
Bob -
Extracting the result of a query into a internal table
Hi,
Does anyone knows or have an idea how to extract the result of a query into a internal table, is there a function module or BAPI?
Thanks in advance,
CKSo then normally I would use a statment like:
IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>BAPI_SALESORDER_GETLIST</b>");
to call a particluar function, but I tried using
IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>BAPI_MDDATAPROVIDERBW_GETCATALOGS</b>");
and it did not seem to work. I also tried -
IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>MDDataProviderBW.GetCatalogs</b>");
How do I format the function?
Thanks
Paul -
Extract the classification data into internal table
Hi all,
I having requirement to extract classification data for material number.
1) Provide the selection option for material number (MATNR).
2) Based on the material number, then extract all that data into internal table as below layout. My problem is how to retrieve the following data from different table based on the MATNR (material number).
Please provide the sample code for select the following data. Thanks.
Classification table
OBJEK (from AUSP table)
MAFID (from AUSP table)
KLART (from AUSP table)
CLASS (from KLAH table)
ATWRT (from AUSP table)
MSEHI (from CABN table)
OBTAB (check if class type=002, set it as MARA)
STDCL (from KSSK table)Hi,
if I understand, you´re trying to get information from the classification system for the material. You can use the following code:
DATA: clases LIKE TABLE OF sclass WITH HEADER LINE,
datos LIKE TABLE OF clobjdat WITH HEADER LINE.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
class = 'DESK' "clase a buscar
classtype = '001' "tipo de la clase
features = 'X'
language = sy-langu
object = 'PM00A000C055' "Material
objecttable = 'MARA'
key_date = sy-datum
initial_charact = 'X'
change_service_clf = 'X'
TABLES
t_class = clases
t_objectdata = datos
EXCEPTIONS
no_classification = 1
no_classtypes = 2
invalid_class_type = 3
OTHERS = 4.
loop at datos.
endloop.
Maybe you are looking for
-
Inserting 10 million rows in to a table hangs
HI through toad iam using a simple for loop to insert 10 million rows into a table by saying for i in 1 ......10000000 insert................. It hangs ........ for lot of time is there a better way to insert the rows in to the table....? i have to t
-
Error when trying to create Graph in jspx. page
Hi! I use JDeveloper 11.1.1.2.0 Jdeveloper! And when I try to add graph in jspx page, then I have error - see http://my.jetscreenshot.com/2677/20100818-1nk7-135kb Can anyone say what is wrong and what to do? Best regards, Debuger Edited by: Debuger o
-
APEX3.0 on Oracle 10.2.0 with OHS 10.1.3.1.0
Hello, I have just installed APEX3.0 on Oracle 10.2.0 with OHS 10.1.3.1.0, which went succesfully. I have configured the HTTP Server as mentioned in the documentation. However, when I try to access the login page at http://localhost/pls/apex/apex_adm
-
Does the current version of PSE support HDR? Thank you. David
-
System ignores automatic reservations when checks availability
Dear colleages I have 1000 units of a material in unrestricted stock of storage location. I configured the system so that it does not allow to reserve a quantity greater than available in unrestricted stock. However, the system is allowing to reserve