Internal table question
Hi Everybody-
I am very new to SAP and i have question regarding internal tables. I have struture called "ZMI_VENDOR_TO_BW_GENERIC_V_TAB" which i get from another sap system thru SAP XI. Now i need to traverse thru this structure and add these values into custom database table. So i have declared an internal table like below
<b>data:itab_venkat type ZMI_VENDOR_TO_BW_GENERIC_V_TAB occurs 10.
data vendorid type c.
itab_venkat = Input-Generic_Vendor-Generic_Vendor_Record1.
LOOP AT itab_venkat.
vendorid = itab_venkat-generic_vendor_id1.
endloop.
</b>
i am getting an error saying occurs cannot be used and also getting an error at the loop statement, Can somebody please correct me, i am very new to SAP.in the loop i am getting the vendor id and then i should update the database table.
Please help me.
Thank you
Venkat
hi venkat,
check these links..
http://cma.zdnet.com/book/abap/index.htm
http://www.sapdevelopment.co.uk/
http://www.sap-img.com/
http://juliet.stfx.ca/people/fac/infosys/abap.htm
http://help.sap.com/saphelp_46c/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_46c/helpdata/en/d6/0db357494511d182b70000e829fbfe/frameset.htm
http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
http://www.sapgenie.com/abap/example_code.htm
http://www.geocities.com/SiliconValley/Campus/6345/abapindx.htm
http://help.sap.com/printdocu/core/Print46c/en/Data/Index_en.htm
http://help.sap.com/saphelp_40b/helpdata/en/4f/991f82446d11d189700000e8322d00/applet.htm
http://www.sap-img.com/abap-function.htm
http://www.sapgenie.com/abap/code/abap19.htm
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.planetsap.com/Tips_and_Tricks.htm
http://help.sap.com/saphelp_40b/helpdata/ru/d6/0dc169494511d182b70000e829fbfe/applet.htm
http://www.henrikfrank.dk/abapexamples/SapScript/symbols.htm
http://www.henrikfrank.dk/abapexamples/index.html
http://sap.ittoolbox.com/documents/document.asp?i=752
http://members.aol.com/_ht_a/skarkada/sap/
http://sappoint.com/abap/
http://members.tripod.com/abap4/SAP_Functions.html
http://members.ozemail.com.au/~anmari/sap/index.html
http://www.planetsap.com/Userexit_List.htm
http://www.planetsap.com/Tips_and_Tricks.htm
http://www.kabai.com/abaps/q.htm
http://www.planetsap.com/Userexit_List.htm
http://help.sap.com/saphelp_bw21c/helpdata/en/c4/3a8090505211d189550000e829fbbd/frameset.htm
http://www.sapgenie.com/abap/bapi/example.htm
http://help.sap.com/saphelp_45b/helpdata/en/65/897415dc4ad111950d0060b03c6b76/content.htm
http://www.sap-basis-abap.com/index.htm
http://help.sap.com/saphelp_40b/helpdata/en/fc/eb2c46358411d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_46c/helpdata/en/aa/aeb23789e95378e10000009b38f8cf/frameset.htm
http://www.geocities.com/ResearchTriangle/1635/system.html
http://www.sapdesignguild.org/resources/MiniSG/3_Managing/3_Functions_Table_Control.htm
http://help.sap.com/saphelp_45b/helpdata/en/d1/801bdf454211d189710000e8322d00/content.htm
http://www.sapfans.com/sapfans/repos/saprep.htm
http://www.planetsap.com/howdo_a.htm
http://help.sap.com/saphelp_util464/helpdata/en/69/c2516e4ba111d189750000e8322d00/content.htm
http://www.sapgenie.com/abap/smartforms_detail.htm
http://www.sap-img.com/abap.htm
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm
http://www.geocities.com/victorav15/sapr3/abap.html
http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
http://abap4.tripod.com/Other_Useful_Tips.html
http://help.sap.com/saphelp_45b/helpdata/en/cf/21ee2b446011d189700000e8322d00/content.htm
http://www.sap-basis-abap.com/sapmm.htm
http://sap.ittoolbox.com/nav/t.asp?t=303&p=448&h1=303&h2=322&h3=448
http://sapfans.com/
http://cma.zdnet.com/book/abap/ch03/ch03.htm
http://help.sap.com/saphelp_40b/helpdata/en/4f/991f82446d11d189700000e8322d00/applet.htm
http://sappoint.com/abap/
http://www.henrikfrank.dk/abapuk.html
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
http://www.sapgenie.com/abap/index.htm
http://www.sap-img.com/abap.htm
http://www.sapdevelopment.co.uk/tips/tipshome.htm
http://help.sap.com/printdocu/core/Print46c/en/Data/Index_en.htm
http://sap.ittoolbox.com/nav/t.asp?t=322&p=322&h1=322
http://sap.ittoolbox.com/nav/t.asp?t=448&p=448&h1=448
http://www.thespot4sap.com/
http://www.kabai.com/abaps/q.htm
http://www.geocities.com/mpioud/Abap_programs.html
http://www.sapgenie.com/abap/tips_and_tricks.htm
http://www.sapassist.com/code/d.asp?whichpage=1&pagesize=10&i=10&a=c&o=&t=&q=&qt=
For FAQ
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.sapgenie.com/faq/abap.htm
Similar Messages
-
Hi All,
How to write the below expression in ABAP,
check, if it_ltap_vb-bwlvs is in internal table it_bwlvs
if yes: continue with First decision.
if no: EXIT.
First Decision,
Secodn Decision.
Please let me know.
Thanks,
KCRHi,
try like this:
<b>
sort it_bwlvs f1.
loop at it_ltap_vb.
read table it_bwlvs with key f1 = it_ltap_vp-f1
binary search.
if sy-subrc = 0.
first condition.
else.
exit.
endif.
</b>
Regards
Shiva -
'Search' internal table - sy-tabix question
I realize there are many questions out there on sy-tabix but non that answer my question.
I have an internal table that will be filled with material numbers (among other things). I need to loop through the internal table to see if the material number already exists in the table. If so I need to store the index of the material number. What is the best way to go about doing this?
Regards,
DavisThanks Ravi, I guess instead of
WRITE: / sy-tabix I can have something like
LineIndex = sy-tabix. is that correct?
I wasn't sure if I could do something like
READ TABLE itab WITH KEY matnr....
I thought that I had to include a string that was searched through the whole table like the example in the online help. Thanks again!
Davis.
I'm keeping this question open to see what other suggestions I receive. -
Question in ABAP syntax, read & insert data from internal table, while loop
Hi, SDN Fellow.
I am from Java background and learnt ABAP, I don't usually write much ABAP code.
I am trying to implement the following logic in a RFC now.
I have one z-custom database table, the structure as the following:
It has two columns, with these sample data.
Says datable table is ZEMPMGRTAB.
EmployeeID,ManagerID
user10,user1
user9,user1
user8,user1
user7,user2
user6,user2
user5,user2
user4,user2
user2,user1
The logic is this:
I have a input parameter, userid. I am using this parameter to have a select statement to query the record into export table,EXPTAB 'LIKE' table ZEMPMGRTAB.
SELECT * FROM ZEMPMGRTAB
into table EXPTAB
WHERE EMPLOYEEID = USERID.
Say, my parameter value, USERID ='USER4'.
Referring to the sample data above, I can get the record of this in my EXPTAB,
EmployeeID,ManagerID
user4,user2
Now, I want to iterately use the EXPTABLE-ManagerID
as the USERID input in SELECT statement, until it has no return result. Then, insert the new records in
EXPTAB.
In above new loop case, we will get this table content in EXPTAB,
EmployeeID,ManagerID
user4,user2
user2,user1
I kind of think of the pseudocode logic as below:
(These may not be a valid ABAP code, so I need help to convert/correct them)
DATA:
IWA TYEP ZZEMPMGRTAB,
ITAB
HASHED TABLE OF ZZEMPMGRTAB
WITH UNIQUE KEY EMPLOYEEID.
SELECT * FROM ZEMPMGRTAB
into table ITAB
WHERE EMPLOYEEID = USERID.
*Question 1: I cannot insert a internal table to export table, it is *incompatible type, what is the alternative way fo this?
*Question 2: How can I access thedata of the internal table like this,ITAB-MANAGERID? As if I can, I would do this:
* IWA-EMPLOYEEE = ITAB-EMPLOYEEID. IWA-MANAGERID = IWA-MANAGERID. INSERT IWA INTO TABLE EXPTAB.
* Question 3: Is the 'NE NULL' - 'not equal to NULL' is right syntax?
IF ITAB NE NULL.
INSERT ITAB INTO EXPTAB.
ENDIF
* Question 4: Is my WHILE loop setup right here? And are the syntax right?
WHILE ITAB NE NULL.
SELECT * FROM ZEMPMGRTAB
into table ITAB
WHERE EMPLOYEEID = ITAB-MANAGERID.
IF ITAB NE NULL.
INSERT ITAB INTO EXPTAB.
ENDIF
REFRESH ITAB.
ENDWHILE.
Assume all the syntax and logic are right, I should get this result:
EmployeeID,ManagerID
user4,user2
user2,user1
If I have a new entry in datable table,ZEMPMGRTAB like this:
user1,user0
My pseudocode logic will get this result:
EmployeeID,ManagerID
user4,user2
user2,user1
user1,user0
I truly appreciate if you can help me to validate the above syntax and pseudocode logic.
Thanks in advance.
KCHi,
FUNCTION ZGETSOMEINFO3.
*"*"Local Interface:
*" IMPORTING
*" VALUE(USERID) TYPE AWTXT
*" VALUE(FMTYPEID) TYPE AWTXT
*" EXPORTING
*" VALUE(RETURN) TYPE BAPIRETURN
*" TABLES
*" APPROVERT STRUCTURE ZTAB_FMAPPROVER
*" ACTOWNERT STRUCTURE ZTAB_FMACTOWNER
DATA: T_RESULT TYPE STANDARD TABLE OF ZTAB_FMAPPROVER.
**Question 1: For this line, I got an error says "Program ''USERID" *not found. Is the syntax right, as the USERID is a parameter for the function.
perform add_line(USERID).
ENDFUNCTION.
form add_line using i_user type ZTAB_FMAPPROVER.EMPLOYEEID
changing T_RESULT TYPE ZTAB_FMAPPROVER.
data: ls_row type ZTAB_FMAPPROVER.
* Get record for i_user
select single * into ls_row from ZTAB_FMAPPROVER
where EmployeeID = i_user.
if sy-subrc NE 0.
* Do nothing, there is not manager for this employee
else.
* Store result
QUESTION 2: I am still got stuck on this line of code. It still *says that "T_RESULT" is not an internal table "OCCURS n" *specification is missing. I thought the line: "T_RESULT TYPE *ZTAB_FMAPPROVER" means declare internal table, T_RESULT as type of ZTAB_FMAPPROVER". Am I understand it wrongly?
append ls_row to t_result.
* Call recursion
perform add_line using ls_row-ManagerID
changing t_result.
endif.
endform.
Thanks,
KC -
HELLOW TO ALL.
Q. HOW TO DISPLAY THE INTERNAL TABLE DATA IN TABLAR FORMAT ?Moderator message - Welcome to SCN
Unfortunately, this forum is not a place to learn ABAP. I suggest that you get one of the good ABAP books that are out there and maybe join an internet forum that caters to beginners.
Do not use all caps.
Please read [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement], How to post code in SCN, and some things NOT to do... and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.
Thread locked.
Rob -
Question about XML mapping to ABAP internal table
Hi experts.
I'm trying to XML mapping. But it doesn't work well. Assume there are XML file as below.
<HEADER>
<ITEM>
<FOO>123</FOO>
<BAR>ABC</BAR>
</ITEM>
<ITEM>
<FOO>456</FOO>
<BAR>DEF</BAR>
</ITEM>
<HEADER>
and I want to trasformation it as below.
ITAB
FOO | BAR
123 | ABC
456 | DEF
How could I trasformation using "call transformation"?
Regards.Hi,
REPORT zind_xml_to_sap NO STANDARD PAGE HEADING.
Data Declaration *
DATA: client TYPE REF TO if_http_client, "Interface
host TYPE string,
port TYPE string,
proxy_host TYPE string,
proxy_port TYPE string,
path TYPE string,
scheme TYPE i,
xml TYPE xstring,
response TYPE string.
DATA: t_xml TYPE smum_xmltb OCCURS 0 WITH HEADER LINE. "XML Table structure used
"for retreive and output XML doc
DATA: g_stream_factory TYPE REF TO if_ixml_stream_factory. "Interface
DATA : return LIKE bapiret2 OCCURS 0 WITH HEADER LINE. "XML Table structure used for retreive
"and output XML doc
Parameters *
PARAMETER : p_add TYPE string LOWER CASE ,
p_dfile LIKE rlgrap-filename.
AT Selection-Screen on value-request for file *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dfile.
Get file
PERFORM 100_get_file.
Start-of-Selection *
START-OF-SELECTION.
Perform to upload xml data from URL to SAP internal table
PERFORM 200_xml_upload.
IF t_xml[] IS NOT INITIAL.
Perform to Download data from Internal Table to a text file in local drive
PERFORM 300_download.
write : / 'Data Uploaded to Internal Table Successfully'.
write : / 'XML Data Downloaded to Local path', p_dfile.
else.
write : / 'No Data for upload'.
ENDIF.
*if t_xml[] is INITIAL.
WRITE : address, 'Given URl cannot be Converted' .
else.
LOOP AT t_xml .
WRITE: t_xml-cname, t_xml-cvalue.
ENDLOOP.
endif.
*& Form get_file
Get File
FORM 100_get_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
file_name = p_dfile
ENDFORM. " 100_get_file
*& Form 200_xml_upload
form to upload xml data from URL to SAP internal table
FORM 200_xml_upload .
*Check HTTP:// and concatenate
IF p_add NS 'http://' OR p_add NS 'HTTP://'.
CONCATENATE 'http://' p_add
INTO p_add.
ENDIF.
Fetching the address of the URL
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = p_add
IMPORTING
client = client.
*Structure of HTTP Connection and Dispatch of Data
client->send( ).
*Receipt of HTTP Response
CALL METHOD client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
IF sy-subrc = 1.
MESSAGE 'HTTP COMMUNICATION FAILURE' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSEIF sy-subrc = 2.
MESSAGE 'HTTP INVALID STATE' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSEIF sy-subrc = 3.
MESSAGE 'HTTP PROCESSING FAILED' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSE.
MESSAGE 'Problem in HTTP Request' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
ENDIF.
Get data of the xml to Response
response = client->response->get_cdata( ).
*FM converting the XML format to abap
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = response
IMPORTING
buffer = xml.
*FM converting XMl to readable format to a internal table.
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xml
TABLES
xml_table = t_xml
return = return.
ENDFORM. " 200_xml_upload
*& Form 300_download
*form to Download data from Internal Table to a text file in local drive
FORM 300_download .
DATA filename TYPE string.
filename = p_dfile.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = filename
WRITE_FIELD_SEPARATOR = 'X'
TABLES
data_tab = t_xml
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. -
Question,Get data from ALV to internal table
Hi, friends
I currently need to get the data displayed on ALV.
But the original internal table is local.
It means it has already been deleted.
Do you know which method I shoud use?
After that, I will move the records to other internal
table.
3Q
MinghanHi,
are you using ALV list/GRID FM,
Check this..,
1. why can't you declare the internal table as Global.
2. you can call the FM
REUSE_ALV_LIST_LAYOUT_INFO_GET
here you get the table data using the table parameter <b>ET_OUTTAB</b>
try this...
where you will try?( when ever you want , please let me know where exactly you need this)
Regards
vijay -
Question about reading csv file into internal table
Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
I would like to ask how can I read a CSV file into internal table from files in application server?
I can't simply use SPLIT as there may be comma in the content. e.g.
"abc","aaa,ab",10,"bbc"
My expected output:
abc
aaa,ab
10
bbb
Thanks again for your help.Hi Gundam,
Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET dsn INTO record.
PERFORM parser USING record.
ENDDO.
*DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
*DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
*DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
*DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
*DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
FORM parser USING str.
DATA field(12).
DATA field1(12).
DATA field2(12).
DATA field3(12).
DATA field4(12).
DATA cnt TYPE i.
DATA len TYPE i.
DATA temp TYPE i.
DATA start TYPE i.
DATA quote TYPE i.
DATA rec_cnt TYPE i.
len = strlen( str ).
cnt = 0.
temp = 0.
rec_cnt = 0.
DO.
* Start at the beginning
IF start EQ 0.
"string just ENDED start new one.
start = 1.
quote = 0.
CLEAR field.
ENDIF.
IF str+cnt(1) EQ '"'. "Check for qoutes
"CHECK IF quotes is already set
IF quote = 1.
"Already quotes set
"Start new field
start = 0.
quote = 0.
CONCATENATE field '"' INTO field.
IF field IS NOT INITIAL.
rec_cnt = rec_cnt + 1.
CONDENSE field.
IF rec_cnt EQ 1.
field1 = field.
ELSEIF rec_cnt EQ 2.
field2 = field.
ELSEIF rec_cnt EQ 3.
field3 = field.
ELSEIF rec_cnt EQ 4.
field4 = field.
ENDIF.
ENDIF.
* WRITE field.
ELSE.
"This is the start of quotes
quote = 1.
ENDIF.
ENDIF.
IF str+cnt(1) EQ ','. "Check end of field
IF quote EQ 0. "This is not inside quote end of field
start = 0.
quote = 0.
CONDENSE field.
* WRITE field.
IF field IS NOT INITIAL.
rec_cnt = rec_cnt + 1.
IF rec_cnt EQ 1.
field1 = field.
ELSEIF rec_cnt EQ 2.
field2 = field.
ELSEIF rec_cnt EQ 3.
field3 = field.
ELSEIF rec_cnt EQ 4.
field4 = field.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
CONCATENATE field str+cnt(1) INTO field.
cnt = cnt + 1.
IF cnt GE len.
EXIT.
ENDIF.
ENDDO.
WRITE: field1, field2, field3, field4.
ENDFORM.
Regards,
Wenceslaus. -
Question reg. modifying latest record in internal table
Can you tell me if it is possible to modify the last appended record to the internal table?
I just want to modify the record in the internal table which is appended at the latest. Please tell me the logic for this.
Thanks a lot,
KrishenHi try with this:
DATA line TYPE I.
DATA wa_itab TYPE LINE OF it_itab.
DESCRIBE TABLE IT_TABLE LINE line.
READ TABLE IT_TABLE INTO wa_itab INDEX line.
WA_TABLE-FIELD = 'new value'.
MODIFY TABLE IT_TABLE FROM wa_itab
TRANSPORTING field.
Best regards. -
What is internal table? read the another questions
What are internal tables? How do you get the number of lines in an internal table? How to use a specific number occurs statement?
send me replay alsohi,
try this links....
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
An internal table is one of two structured data types in ABAP. It can contain any number of identically structured rows, with or without a header line.
The header line is similar to a structure and serves as the work area of the internal table. The data type of individual rows can be either elementary or structured.
Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.
Fields of Internal Tables
SY-TABIX
Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.
APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.
COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.
LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.
READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.
SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search string is found.
SY-TFILL
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL contains the number of lines in the relevant internal table.
SY-TLENG
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the length of the lines in the relevant internal table.
SY-TOCCU
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the initial amount of memory allocated to the relevant internal table.
i think this will solve your problem don't forget to reward points.
regards, -
Question on internal table logic..
Gurus,
I have a internal table as follows:
it_tab:
ID---ACTION---CHANGE
A1-----X--
B2----
U
C1-----X--
U
C2-----X--
Without looping at the table, how can I find get the result that the internal table has 3 ids with ACTION ='X'
and 1 ID with ACTION = X and Change = U.
Regards,
Rajesh.I agree with Rob, why not loop?
First thing without loop that comes to mind is
Using the Read statement 4 times with index 1,2,3 & 4.
Regards,
DNP -
Question on Dynamic Internal Table creation
Good day everyone.
I would like to ask if it is possible to just add several fields to an existing internal table to make it dynamic? if possible, does anyone have a sample program? thanks a lot!Hi Christian,
Refer the following code. It may help you.
Reward points if it helps.
REPORT ZDSAP .
DATA: d_ref TYPE REF TO data,
d_ref2 TYPE REF TO data ,
i_alv_cat TYPE TABLE OF lvc_s_fcat,
ls_alv_cat LIKE LINE OF i_alv_cat.
TYPES tabname LIKE dcobjdef-name .
parameter: p_tablen type tabname.
data: begin of itab occurs 0.
INCLUDE STRUCTURE dntab.
data: end of itab.
FIELD-SYMBOLS : <F_FS> TYPE table,
<F_FS1> TYPE TABLE,
<F_FS2> TYPE ANY,
<F_FS3> TYPE TABLE.
REFRESH itab.
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
tabname = p_tablen
TABLES
nametab = itab
EXCEPTIONS
no_texts_found = 1.
LOOP AT itab .
ls_alv_cat-fieldname = itab-fieldname.
ls_alv_cat-ref_table = p_tablen.
ls_alv_cat-ref_field = itab-fieldname.
APPEND ls_alv_cat TO i_alv_cat.
ENDLOOP.
* internal table build
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = i_alv_cat
IMPORTING ep_table = d_ref .
ASSIGN d_ref->* TO <F_FS>.
SELECT * FROM (p_tablen) INTO CORRESPONDING FIELDS OF TABLE <F_FS>.
LOOP AT <F_FS> ASSIGNING <F_FS2>.
*your code goes here.
ENDLOOP. -
Dumb question about monodimensional internal tables
Hi all gurus,
in ABAP/4 it is possible to define an internal table made up by a single field , so that we could consider such a declaration:
DATA: itab TYPE TABLE OF EBELN
as a single-dimension array.
Now, supposing I want to fast access this vector directly with a read table... I don't have an explicit field name to refer to in the WITH KEY clause.
My workaround actually is to define such a vector in this way:
DATA: begin of itab,
doc_no TYPE EBELN,
end of itab.
so that a fast READ TABLE statement can be possible specifying the WITH TABLE clause in this way:
READ TABLE itab WITH KEY doc_no = <valuetosearchfor> .
Anyway, I'm wondering if these ops are possible even in an itab defined in the first form, without the need of defining a specific itab structure. In many situation I find mono-dimensional tables really useful, I'd like to avoid every time an explicit DATA type def.Hello,
I dont know if this is what you are looking for. You can use the addition:
... WITH TABLE KEY [keyname COMPONENTS] ...
SAp documentation also adds:
The pseudo component table_line can be specified as a component for tables with an unstructured row type, if their whole table entry is defined as a table key.
For more details on psuedo components read this : [http://help.sap.com/abapdocu_70/en/ABENITAB_COMPONENTS.htm|http://help.sap.com/abapdocu_70/en/ABENITAB_COMPONENTS.htm]
Hope this helps.
BR,
Suhas -
Question about Subroutine and Internal tables
See I have this code.
TABLES: SFLIGHT.
TYPES: BEGIN OF LINE,
Carrid like SFLIGHT-CARRID,
Connid like SFLIGHT-CONNID,
Fldate like SFLIGHT-FLDATE,
Seatsmax like SFLIGHT-SEATSMAX,
Seatsocc like SFLIGHT-SEATSOCC,
Percen type p decimals 2,
END OF LINE.
DATA: ISFLIGHT TYPE STANDARD TABLE OF LINE INITIAL SIZE 10 WITH HEADER LINE.
DATA: Percent type p decimals 2.
PARAMETERS: CID LIKE SFLIGHT-CARRID.
DATA: Num type I value 0.
INITIALIZATION.
CID = '004'.
SELECT CARRID CONNID FLDATE SEATSMAX SEATSOCC FROM SFLIGHT INTO TABLE ISFLIGHT WHERE CARRID = CID.
So far I've gotten this far. but now I need to compute for the percentage, which I'm required to do in a subroutine.
So I tried
FORM U TABLES ISFLIGHT STRUCTURE SFLIGHT.
ISFLIGHT-Percen = ( ISFLIGHT-Seatsocc / ISFLIGHT-Seatsmax ) * 100.
ENDFORM.
But I keep getting an error o that. It keeps telling me that ISFLIGHT does not have a Percen field. Also I'm suppose to use a pass by value to this subroutine but I don't know what that means.
Basically I need to compute for the percentage and insert it tot he internal table. which I would sort by percentage. After which I'm suppose to print the ouput by passing the internal table to the subroutine.
I know I'm doing something wrong but I just don't know how to fix this since I only started working on subroutines today. Any help would be appreciated.Hi.
line defined in data dictionary. Try this:
TABLES: sflight.
DATA: BEGIN OF my_line,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
seatsmax LIKE sflight-seatsmax,
seatsocc LIKE sflight-seatsocc,
percen TYPE p DECIMALS 2,
END OF my_line.
DATA: isflight LIKE my_line OCCURS 10 WITH HEADER LINE.
DATA: percent TYPE p DECIMALS 2.
PARAMETERS: cid LIKE sflight-carrid.
DATA: num TYPE i VALUE 0.
INITIALIZATION.
cid = '004'.
SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO TABLE
isflight WHERE carrid = cid.
FORM u TABLES isflight STRUCTURE my_line.
isflight-percen = ( isflight-seatsocc / isflight-seatsmax ) * 100.
ENDFORM. "U
regards
Walter Habich -
Unable to Capture ALV output in an Internal Table, after CALL TRANSACTION
Dear all,
My requirement is to run multiple materials in T-code CK86_99 but as we know CK86_99 is only adequate to one material at a time.
So, I want to capture the Output of the T-code in my Internal table with respect to all the Material Numbers I use in the Select-Options of my Z Program.
Below is the Code I developed so far, but the Class
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lf_ref ).
is not capturing the Ouput...
Please have a look and enlighten me how it could be solved.
TABLES : mara.
DATA : BEGIN OF wa_mara,
matnr TYPE mara-matnr,
END OF wa_mara.
DATA: it_bdcdata TYPE TABLE OF bdcdata,
wa_it_bdcdata LIKE LINE OF it_bdcdata,
it_mara LIKE TABLE OF wa_mara.
* BELNR(10).
FIELD-SYMBOLS:<fs_tab> TYPE ANY TABLE,
<fs_line> TYPE any.
DATA:lf_ref TYPE REF TO data,
lf_ref1 TYPE REF TO data.
SELECT-OPTIONS so_matnr FOR mara-matnr.
PARAMETERS p_werks LIKE t001w-werks.
*BELNR = 'Z92'. " Give Document Number here
SELECT matnr FROM mara INTO TABLE it_mara WHERE matnr IN so_matnr.
DATA opt TYPE ctu_params.
LOOP AT it_mara INTO wa_mara.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-program = 'SAPMKKB0'.
wa_it_bdcdata-dynpro = '0300'.
wa_it_bdcdata-dynbegin = 'X'.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'BDC_CURSOR'.
wa_it_bdcdata-fval = 'KKB0-MATNR'.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'KKB0-MATNR'.
wa_it_bdcdata-fval = wa_mara-matnr.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'BDC_CURSOR'.
wa_it_bdcdata-fval = 'KKB0-WERKS'.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'KKB0-WERKS'.
wa_it_bdcdata-fval = p_werks.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'BDC_OKCODE'.
wa_it_bdcdata-fval = 'OSNY'."'ONLI'."=CRET'.
APPEND wa_it_bdcdata TO it_bdcdata.
* CLEAR wa_it_bdcdata.
* wa_it_bdcdata-program = 'SAPLKKRSOO'.
* wa_it_bdcdata-dynpro = '0100'.
* wa_it_bdcdata-dynbegin = 'X'.
* APPEND wa_it_bdcdata TO it_bdcdata.
* CLEAR wa_it_bdcdata.
* wa_it_bdcdata-fnam = 'BDC_OKCODE'.
* wa_it_bdcdata-fval = 'BACK'."=CRET'.
* APPEND wa_it_bdcdata TO it_bdcdata.
* CLEAR wa_it_bdcdata.
* wa_it_bdcdata-program = 'SAPMKKB0'.
* wa_it_bdcdata-dynpro = '0300'.
* wa_it_bdcdata-dynbegin = 'X'.
* APPEND wa_it_bdcdata TO it_bdcdata.
* CLEAR wa_it_bdcdata.
* wa_it_bdcdata-fnam = 'BDC_OKCODE'.
* wa_it_bdcdata-fval = 'EXIT'."=CRET'.
* APPEND wa_it_bdcdata TO it_bdcdata.
opt-dismode = 'N'.
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_true
data = abap_true ).
CALL TRANSACTION 'CK86_99' USING it_bdcdata OPTIONS FROM opt.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lf_ref ).
ASSIGN lf_ref->* TO <fs_tab>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE 'Unable to retrieve ALV data' TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
IF <fs_tab> IS ASSIGNED.
CREATE DATA lf_ref1 LIKE LINE OF <fs_tab>.
ASSIGN lf_ref1->* TO <fs_line>.
ENDIF.
*LOOP AT <FS_TAB> ASSIGNING <FS_LINE>.
*ENDLOOP.Hi Abhay,
If you go to Transaction code SE93, enter the tcode "CK86_99" and click display, you may see the default value for transaction is "KKBB" and the screen field for P_SCREEN = 0300, P_TCODE = ck86_99.
You may need to copy the transaction code "KKBB" and go to SE93 again, enter the tcode for "KKBB" then click display, now you may see the program name is "RKKB1000".
Hope this answer your question.
Thanks
Hock Lin
Maybe you are looking for
-
The 4 or 5 finger gesture does nothing on my iPad 1. Why?
I've read the manual in the over view and don't see that it is only applicable to iPad 2...
-
I loaded actions into my PSE 10, then when I restarted my PC (windows 7) and PSE 10 I got a Runtime Error (Microsoft Visual C Runtime Library)
-
Full-screen terminal dims display
Hi, when switching to full-screen for Terminal my external display reduces its brightness to an irritating degree. Brightness level are back to normal when the menu is displayed or other windows are on top of the terminal (for example the preferences
-
Seeing multiple file download dialogs trying to download one file.
I'm seeing some strange behavior from an application that uses the Safari Webkit to download a file from within the app. When I click the 'download' button I get cascading file download dialog boxes. Sometimes it is only two and sometimes it is 15+.
-
I have recently upgraded the essbase on unix from 9.3.0.1 to 9.3.1. During the upgarde there was no problem it looks like it went smoothly. However, I could not retrieve data from excel addin or even from Adminstration console. The error message I ge