Reading table clusters ex CDCLS
Hi Experts,
When trying to load table from table cluster CDCLS into an internal table the field VARDATA has the data 0001000100014344504F5320202020200290008300010131050000121F9D0267ACFA8CAC7A0C4CCE2E01FEC10A2010626064AC800F189A608A9108BC5D233105E1
this data appears to be in hex format can this be decoded into BIN format.
Thanks and Regards,
Shravan.
Hi shravan,
1. EG Table MONI field Clustd , contains RAW DATA
SO THE FIRST THING IS TO KNOW WHICH KIND OF DATA
IE. FIELDS, INTERNAL TABLE ETC.
IT CONTAINS.
This can be known via IMPORT Command.
Sample Program is:
DATA : CDIR LIKE TABLE OF CDIR WITH HEADER LINE.
IMPORT META DATA
IMPORT DIRECTORY INTO CDIR FROM DATABASE MONI(DB)
ID 'SYSEVENT20041008074601'.
BREAK-POINT.
just look into internal table CDIR, it contains 3 fields.
1 SY-DATUM -- FIELD
2. SY-UZEIT --- FIELD
3. V_SYSTEM_EVENT_TAB -- TABLE
2. NOW TO GET DATA U CAN AGAIN USE IMPORT COMMAND
DATA : MYDATE TYPE SY-DATUM.
IMPORT SY-DATUM TO MYDATE FROM DATABASE MONI(DB)
ID 'SYSEVENT20041008074601'.
BREAK-POINT.
3. JUST TAKE CARE OF
A: DB
B: SYSEVENT20041008074601
A and B should be in your moni table.
4. for the 3rd field, V_SYSTEM_EVENT_TAB
I don't know what is the related structure.
(im still searching for it)
otherwise we can import it in the same way,
by declaring an internal table of the related
structure.
HOPE THIS HELPS.
Regards,
Amit Mittal.
Similar Messages
-
Sy-tabix in relation to LOOP AT and READ TABLE
Hi All,
As per SAP documentation,
1) While looping through an internal table (LOOP AT), sy-tabix contains the index number of current row(for standard and sorted tables)
2)When successfully reading from an internal table(READ TABLE), sy-tabix is set to the index of the result row.
But what happens when READ TABLE is used while looping through another internal table?
i.e. Loop at TAB1...
write sy-tabix.
READ TABLE TAB2...
write sy-tabix.
endloop.
If we are looping through 1st row of TAB1 and the result of read statement is found in 3rd row of TAB2, I expected that sy-tabix before READ would be 1 and after the READ be 3.
But, I found that sy-tabix remains unchanged at 1. Can someone expalin why?
Thanks,
JaganHi
If after reading the table TAB2 the system variable SY-TABIX has still the previous value, that menas the READ TABLE fails or it was read the first record of TAB2.
After READ TABLE TAB2 try to check the SY-SUBRC:
LOOP AT TAB1.
WRITE: / 'TAB1 index:', SY-TABIX.
READ TABLE TAB2 .........
IF SY-SUBRC = 0.
WRITE: 'TAB2 index:', SY-TABIX.
Try this:
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1,
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
FIELD1,
END OF ITAB2.
DATA: INDEX TYPE I.
DO 10 TIMES.
APPEND ITAB.
ENDDO.
DO 10 TIMES.
APPEND ITAB2.
ENDDO.
LOOP AT ITAB.
WRITE: / 'ITAB:', SY-TABIX.
INDEX = SY-TABIX + 2.
READ TABLE ITAB2 INDEX INDEX.
IF SY-SUBRC = 0.
WRITE: 'ITAB2:', SY-TABIX.
ENDIF.
ENDLOOP.
Max -
Conflict: READ TABLE itab2 INDEX 1 vs Modify itab1 from index sy-tabix
The below simple code is for each itab1 line, create a new itab2 by using select statement, and then grab the max value of field f in itab2 and fill it into a corresponding field in itab1.
However the statement:
READ TABLE itab2 into gs_itab1 INDEX 1.
causes the conflict with our another statement in the end of itab1 loop:
Modify itab1 from gs_itab1 index sy-tabix.
that the below Modify statement always modify itab1 at 1st row and also causes an unlimited loop that the program is hung up. Our code looks as the following:
Loop AT itab1 into gs_itab1.
use Select statement to fill in itab2...
SORT itab2 BY f DESCENDING. "f is a field of itab2
READ TABLE itab2 into gs_itab1 INDEX 1.
Modify itab1 from gs_itab1 index sy-tabix.
EndLoop.
However the last two lines of statements in the itab1 loop causes the program hang!
Any solution?
Thanks in advance!Hi,
I got confused while going thru the code...
according to code
first u loop itab1 and get tht in gs_itab1 and then a select query to get data from some table and store in itab2.
Here are u using any where condition, if yes u may probably check aganst gs_itab1 rite? if yes
first suggestion...why cant u put the select statement above the loop and get all the values to an internal table and then read the internal table in the loop stmt. Yes i can see u r sorting it based on some 'f'..just a suggestion
Now here can u follow this code...
Loop AT itab1 ASSIGNING <fs_itab1>,
use Select statement to fill in itab2...
SORT itab2 BY f DESCENDING. "f is a field of itab2
READ TABLE itab2 into <fs_itab1> index 1.
EndLoop.
Please let me know if its not ok
<REMOVED BY MODERATOR>
Regards,
ABAPer007
Edited by: Alvaro Tejada Galindo on Apr 11, 2008 12:26 PM -
How to get the number of hits ("returned rows") in read table statement
Hi Experts
I have the statement shown below, which seems not to work as I would like it to. My problem is that I would like to do two different things depending on weather or not a read table statement results in 0 hits or 1 (or more) hits.
READ TABLE g_ship_item
WITH KEY
l_ztknum = DATA_PACKAGE-/bic/ztknum
BINARY SEARCH.
IF sy-subrc is initial.
no hits found
DATA_PACKAGE-/BIC/ZSTAGEERR = 1.
ELSE.
hits where found and we will do something else...
DATA_PACKAGE-/BIC/ZSTAGEERR = 0.
Hope someone can help me out of my problem...
Thanks in advance, regards
TorbenHi,
As you are using READ statement with Binary search, check whether the internal table g_ship_item is sorted with field /bic/ztknum or not. If it is not sorted then the result of this READ statement is not correct.
Below is the correct code.
sort g_ship_item by /bic/ztknum.
READ table g_ship_item with key g_ship_item = xxx.
Thanks,
Satya -
Dear All,
Please let me know which one of the two should I use to improve the performance, for tables containing a lot of data ?
Regards,
Thanks in anticipation.
Alok.Hi,
Follow below steps.
In se30 transaction you can look for
Tip&TRicks button on application toolbar
apart from below conventions
Follow below steps
1) Remove corresponding from select satement
2) Remove * from select
3) Select field in sequence as defined in database
4) Avoid unnecessary selects
i.e check for internal table not initial
5) Use all entries and sort table by key fields
6) Remove selects ferom loop and use binary search
7) Try to use secondary index when you don't have
full key.
8) Modify internal table use transporting option
9) Avoid nested loop . Use read table and loop at itab
from sy-tabix statement.
10) free intrenal table memory wnen table is not
required for further processing.
11)
Follow below logic.
FORM SUB_SELECTION_AUFKTAB.
if not it_plant[] is initial.
it_plant1[] = it_plant[].
sort it_plant1 by werks.
delete adjacent duplicates from it_plant1 comparing werks
SELECT AUFNR KTEXT USER4 OBJNR INTO CORRESPONDING FIELDS OF TABLE I_AUFKTAB
FROM AUFK
FOR ALL ENTRIES IN it_plant1
WHERE AUFNR IN S_AUFNR AND
KTEXT IN S_KTEXT AND
WERKS IN S_WERKS AND
AUART IN S_AUART AND
USER4 IN S_USER4 AND
werks eq it_plant1-werks.
free it_plant1.
Endif.
ENDFORM. "SUB_SELECTION_AUFKTAB
Regards
Amole -
Invalid Cursor when I want to modify itab with READ TABLE ?
Following code causes a core dump and says invalid cursor.
What should I do if I want to change gt_itab .?
REPORT ZEV_READ_TABLE.
data: begin of gt_itab occurs 0,
key like vbrk-vbeln,
name(10) type C,
amount type i,
end of gt_itab .
start-of-SELECTION.
gt_itab-key = 1.
gt_itab-name = 'erkan'.
gt_itab-amount = 10.
append gt_itab.
gt_itab-key = 2.
gt_itab-name = 'dilem'.
gt_itab-amount = 20.
append gt_itab.
LOOP AT gt_itab.
write:/ gt_itab-key,
gt_itab-name,
gt_itab-amount.
ENDLOOP.
Read table gt_itab with key Key = 1.
if sy-subrc = 0.
gt_itab-amount = 100.
modify gt_itab.
endif.
Kind Regards.
Erkan VAROLChange the code this way & try
modify gt_itab index sy-tabix.
a® -
Field symbols and READ TABLE with system code 4
Hi,
I have a hashed table and I am using field symbols to point to it to retrieve the field content. I then use it in the READ TABLE statement in the following way:
Loop at x_data assign <fs>.
ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c1>.
ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c2>.
READ TABLE ZZZZ assign <fs> with table key a1 = <c1>
a2 = <c2>.
If sy-subrc = 0.
endif.
I ran the debugger and I keep getting a 4. I am not able to get the value from a1 and a2 to see what it is and why it is causing a 4 sy-subrc. I know the value from the hashed table and the values c1 and c2 are the same, so the sy-subrc should be 0.
How would I read a hashed table using field symbols? I know that usig a standard table, I have to sort the table on the key fields() before I actually can do the READ TABLE using the binary search.
Please advise. Thanks
RTHai Rob
Go through the following Code
Field-Symbols are place holders for existing fields.
A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.
Field-Symbols are like Pointers in Programming language C .
Syntax check is not effective.
Syntax :
Data : v1(4) value abcd.
Field-symbols <fs>.
Assign v1 to <fs>.
Write:/ <fs>.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
<FS>-COL2 = 100.
READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
DELETE ITAB INDEX 3.
IF <FS> IS ASSIGNED.
WRITE '<FS> is assigned!'.
ENDIF.
LOOP AT ITAB ASSIGNING <FS>.
WRITE: / <FS>-COL1, <FS>-COL2.
ENDLOOP.
The output is:
1 1
2 100
4 16
Thanks & regards
Sreenivasulu P -
Hi EXpert,
I have an internal table say itab and I need to fetch a single record with some given conditions.
Hence I have used READ table statement ,
But on using this read table statement , I am unable to fetch the record :-(((( . It gives sy-subrc = 4.
And the same conditions when are put in Loop at itab statement, then I am able to fetch the data .
My requirement is only 1 record for the given conditions ( in where clause in case of loop at statement).
I think I am probably missing out on some minor thing..
<removed_by_moderator>
Warm Regards,
SUDHA
Edited by: Julius Bussche on Feb 7, 2009 2:48 PMHi,
Test the following Code hope it will solve out your problem,
PARAMETERS: key TYPE i .
TYPES: BEGIN OF t_test,
s_no TYPE i,
name(15),
END OF t_test.
DATA: it_test TYPE STANDARD TABLE OF t_test WITH HEADER LINE.
DO 10 TIMES.
it_test-s_no = sy-index.
it_test-name = 'SDN'.
APPEND it_test TO it_test.
ENDDO.
READ TABLE it_test INTO it_test WITH KEY key.
IF sy-subrc = 0.
WRITE: 'sy-subrc = ' , sy-subrc,
/1 it_test-s_no, 15 it_test-name.
ELSE.
WRITE: 'sy-subrc = ' , sy-subrc,
/ 'Sorry there is no Records with this Key'.
ENDIF.
Kind Regards,
Faisal
Edited by: Faisal Altaf on Feb 7, 2009 6:59 PM -
RFC and read table in another destination
HI
I search a complete code to read a table using the function 'RFC_GET_TABLE_ENTRIES '
I can acess to another server using RFC without problem.
I need to read table 'tmsbuftxt ' and data ' TRKORR '.
my program looks like
TABLES:
tmsbuftxt.
DATA:
i_tab512 TYPE tab512 OCCURS 0 WITH HEADER LINE,
i_tmsbuftxt TYPE table of tmsbuftxt,
st_tmsbuftxt type tmsbuftxt.
PARAMETERS p_dest LIKE rfcdes-rfcdest OBLIGATORY.
START-OF-SELECTION.
CLEAR i_tab512. REFRESH i_tab512.
CALL FUNCTION 'RFC_GET_TABLE_ENTRIES'
DESTINATION
p_dest
EXPORTING
" BYPASS_BUFFER = ' '
" FROM_KEY = ' '
" GEN_KEY = ' '
" MAX_ENTRIES = 0
table_name = 'tmsbuftxt'
" TO_KEY = ' '
" IMPORTING
"* NUMBER_OF_ENTRIES =
TABLES
entries = i_tab512
EXCEPTIONS
OTHERS = 1.
i_tmsbuftxt[] = i_tab512[].
LOOP AT i_tmsbuftxt INTO st_tmsbuftxt.
Write : st_tmsbuftxt-TRKORR.
ENDLOOP.
The problem is I dont know how to use the function correctly , I can choose the RFC I want but my programm return nothing.
Anyone can corect this?
I just start develop abap since 1 month.
I just want write st_tmsbuftxt-TRKORR. who is in another environnement using RFC.Hello Guillaume,
welcome in this forum.
I try RFC_GET_TABLE_ENTRIES, but I think it is better to use RFC_READ_TABLE. Try this to get the numbers of the transports from another system:
"-Begin-----------------------------------------------------------------
Program Z_TEST.
Data Fields Type Standard Table Of RFC_DB_FLD.
Data Field Type RFC_DB_FLD.
Data Data Type Standard Table Of TAB512.
Data Line Type TAB512.
Field-FIELDNAME = 'TRKORR'.
Append Field To Fields.
Call Function 'RFC_READ_TABLE' Destination 'NONE'
Exporting
QUERY_TABLE = 'TMSBUFTXT'
Tables
FIELDS = Fields
DATA = Data
Exceptions
TABLE_NOT_AVAILABLE = 1
TABLE_WITHOUT_DATA = 2
OPTION_NOT_VALID = 3
FIELD_NOT_VALID = 4
NOT_AUTHORIZED = 5
DATA_BUFFER_EXCEEDED = 6
Others = 7.
If sy-subrc <> 0.
Else.
Loop At Data Into Line.
Write: / Line.
EndLoop.
EndIf.
"-End-------------------------------------------------------------------
Let us know your results.
Cheers
Stefan -
Performance syntax loop at and read table
in the routine , for reading one line in a internal table , the syntaxe
loop at xxx where and read tabl exxx with key XXXX
has a great difference on performance or not?Loop at statement is used only for processing multiple records.Read table is used for reading a particluar record of an internal table.If you just need to check whether record exists in internal table, use can sort and use binary search with TRANSPORTING NO FIELDS addition. Also, try to use field symbols so that performance is increased.
-
Hi,
I would like to seek advice on this.
I have 2 internal table as below. The problem is although i have the same set of data in both internal table but
why sy-subrc still returns 4. I found out anln2 map to different ones. Why read table not able to pick the same anln2 even though it has the same value of anln2 in itab2.
LOOP AT it_itab1 INTO wa_itab1.
READ TABLE it_itab2 INTO wa_itab2
WITH KEY glla = wa_itab2-glia
cctrla = wa_itab2-cctria
anln1 = wa_itab2-anln1
anln2 = wa_itab2-anln2.
IF sy-subrc = 0.
ThanksDear Please check the below code
same as urs but small mofications
>
Ask_que wrote:
> Hi,
> I would like to seek advice on this.
> I have 2 internal table as below. The problem is although i have the same set of data in both internal table but
> why sy-subrc still returns 4. I found out anln2 map to different ones. Why read table not able to pick the same anln2 even though it has the same value of anln2 in itab2.
>
> LOOP AT it_itab1 INTO wa_itab1.
> READ TABLE it_itab2 INTO wa_itab2
> WITH KEY glla = wa_itab1-glia
> cctrla = wa_itab2-cctria
> anln1 = wa_itab2-anln1
> anln2 = wa_itab2-anln2.
> IF sy-subrc = 0.
>
>
> Thanks
LOOP AT it_itab1 INTO wa_itab1.
READ TABLE it_itab2 INTO wa_itab2
WITH KEY glla = wa_itab1-glia
IF sy-subrc = 0.
cctrla = wa_itab1-cctria
anln1 = wa_itab1-anln1
anln2 = wa_itab1-anln2.
ENDIF.
ENDLOOP.
Thanks
Surendra P -
Hi,
How can i read this table with where condition in OOPS? is it possible?
Give some idea how to proceed?
Inside method i have written like this.
ret is my return parameter.
code:
Loop at me->s001_raw[] assigning <arr_s001>.
read table ret[] with table key
vkorg in me->select_parameters->SO_VKORG[]
and ZZEMP in me->select_parameters->SO_empl[].
assigning <arr_return>.
ThanksRead will not work
May be you can try this way
Loop at me->s001_raw[] assigning <arr_s001>.
loop at ret[] assigning <arr_return> where vkorg in me->select_parameters->SO_VKORG[]
and zzemp in me->select_parameters->SO_empl[].
exit.
endloop.
endloop.
a® -
"Read table" and field symbols
Hello all,
I have a (hopefully simple) question. Let's suppose I want to do the following:
loop at itab1 assigning <fs1>.
read table itab2 assigning <fs2> with table key <fs1>-field1.
if sy-subrc eq 0.
move <fs2>-field1 to ls_out-field1.
endif.
read table itab3 assigning <fs3> with table key <fs1>-field2.
if sy-subrc eq 0.
move <fs3>-field1 to ls_out-field2.
endif.
endloop.
It's also possible to do the following instead:
loop at itab1 assigning <fs1>.
unassign: <fs2>,
<fs3>.
read table itab2 assigning <fs2> with table key <fs1>-field1.
read table itab3 assigning <fs3> with table key <fs1>-field2.
if <fs2> is assigned.
move <fs2>-field1 to ls_out-field1.
endif.
if <fs3> is assigned.
move <fs3>-field1 to ls_out-field2.
endif.
endloop.
My question is: is it "better" to check sy-subrc after each read, and then do a move statement within that if statement, or is it better to check whether the field symbol is assigned each time I want to fill in a field and read everything at the same time?
I'm only really concerned about the case where you don't want to drop out of the loop after the read (so if the read fails you just don't fill any data in). I'm also discounting potential human error (otherwise the sy-subrc method wins hands-down).Just to close this one (albeit somewhat belatedly). I asked Harry Dietz (the ABAP Performance blogging fella) what he would suggest, and he says sy-subrc all the way. Checking that an integer is zero is considerably faster than checking for the assignment, or otherwise, of a field symbol. Furthermore, whilst the field symbol method has the potential to be faster than the sy-subrc method given some compiler optimizations, unfortunately these optimizations don't exist in the ABAP compiler - they're there in the Java compiler though! Shame really. Apparently the ABAP compiler is a pretty simple beast.
Anyway - thanks Harry for clearing this one up! -
Function modules to read Time clusters B1 and B2 from PCL1 and PCL2
Hi All
Are there any function modules or macros to read time clusters B1 & B2?
I want to read time data in the clusters for reporting purpose.
Regards,
Rupesh MhatreYou can also call the FM HR_TIME_RESULTS_GET and get the exact cluster you need from B2 like WPBP, ZE, SALDO etc.
Otherwise if you want to use the older FM declare the GET_TBUFF and GET_BUFFER_DIR as of below structure.
DATA: BEGIN OF TBUFF OCCURS 5000. "XPMK014785
INCLUDE STRUCTURE PCL1.
DATA: SGART(2),
END OF TBUFF.
DATA: BEGIN OF BUFFER_DIR OCCURS 2000, "XPMK014785
SGART(2),
CLIENT LIKE PCL1-CLIENT,
RELID LIKE PCL1-RELID,
SRTFD LIKE PCL1-SRTFD,
NTABX LIKE SY-TABIX, "pointer auf aktuellen satz
OTABX LIKE SY-TABIX, "pointer auf alten satz (falls vorhanden)
NNUXT LIKE PCL1-SRTF2, "anzahl folgesaetze aktueller Satz
ONUXT LIKE PCL1-SRTF2, "anzahl folgesaetze alter Satz
ofset(3) type p, "offset innerhalb eines entry
END OF BUFFER_DIR.
INT_TIME_RESULTS should be of type PTM_TIME_RESULTS.
Regards
Ranganath -
How to assigne multiple value in key of read table
Hi gurus,
I want read table xxxx with key field1 = ' xxx' or field1 = 'yyy'.
how to assign multiple value as key for the same field while reading internal table.
Regards
sagarHi ,
You can loop the internal table like
loop at <table xxxx> where field1 = ' xxx' or field1 = 'yyy'
or you can write two read statements to read the internal table in wrk area.
read table <table xxxx> with key field1 = ' xxx'.
if sy-subrc <>0
read table <table xxxx> with key field1 = 'yyy'.
if sy-subrc = 0
endif.
else.
do your data processing.
endif.
Thans.
Maybe you are looking for
-
Weblogic Server 8.1 giving weird error while deploying EJB
Hi All, I am using weblogic8.1 server with service pack 4. I am trying to deploy an entitybean (ejb2.0) specification. I am getting following error. ========================================================== [Deployer:149033]preparing application sum
-
Elimination of screens for shopping with CCM catalog
Hello CCM seniors, We have installed CCM 2.0 as an add on for SRM 4.0. CCM and EBP are mountd on same server and same client. CAT and CSE also share single client. EBP to CCM integration is working fine. i.e. user can select catalog items and can mak
-
Disk utility Q: setting up RAID with 2 firewire drives
Hi, I tried setting up a redundant RAID with two LaCie 250gb firewire drives in Apple's Disk Utility. All was OK until I restarted. The RAID didn't show up, and both disks came up as unreadable. I was unable to reformat, erase, repair, or partition e
-
Delivery the product from other plant directly
hi we have 2 companies A, B. Company A receive order and give Company B to production, then Company B directly ship to customer. We are using deliviery plant for this scenario. However, sometimes the production will via Company A, then Company A deli
-
Organizing images for a photo album (to be printed) not working as expected
I am trying to create a group of selects from a vacation from which I will print 40 non-snorkeling photos to put in a physical photo album. Here’s what I’m doing: Created project Hawaii, imported about 400 images. Created keywords "Hawaii", “Snorkeli