Collection in ABAP
Hello Friends,
Is there some kind of collection or Array concept in ABAP, Like in JAVA ( Java.util.Collection)??
In loop I want to take values 1 by 1 and store it in some kind of collection ??
Many thanks
Marek
Hi Marek
As Suekrue stated, in ABAP the closest concept to an "array" is an "internal table". You can think of them as structured and semanticly-defined matrices. They are like database tables, but are not persistent i.e their lifetime is the programs' runtime.
You can define an internal table in various ways.
<u><b>e.g.</b></u>
DATA: BEGIN OF gt_itab OCCURS 0 ,
<colmun_1> LIKE/TYPE <data_element/variable> ,
<colmun_2> LIKE/TYPE <data_element/variable> ,
<colmun_n> LIKE/TYPE <data_element/variable> ,
END OF gt_itab .
With this data declaration, you define an internal table having n columns and several rows (row number is not indicated).
Alternatively, you can define internal table type at data dictionary and refer to them as
DATA gt_itab TYPE <DDIC_table_type> .
or you can refer a structure to be the row-type of an internal table as:
DATA gt_itab LIKE <DDIC_structure> OCCURS 0 .
However, reaching to specific records is not done directly indicating the coordinate. You read rows to a work area and reach its field by "-" operator.
<b><u>e.g.</u></b>
READ TABLE gt_itab INTO gs_itab INDEX 5 . "read fifth row"
WRITE:/ gt_itab-<column_name> .
For more information, I strongly recommend you to inspect SAP Online Help whose address was mentioned at Sidharth's post and the book
<a href="http://www.sap-press.com/product.cfm?account=&product=H958">"ABAP Objects The Official Reference" A comprehensive guide to all ABAP language elements</a>
by Horst Keller & Joachim Jacobitz
or
"ABAP Objects: Introduction to Programming SAP Applications" by Horst Keller, Sascha Kruger.
*--Serdar
Message was edited by: Serdar Simsekler
Similar Messages
-
Best possible way to achieve HashMap (Java Collection) in ABAP
Hi
I need to store name-value pair at runtime, where name act as a key (something what HashMap provides in Java). What is the best possible approach to do this?
I can create a Structure (having two fields name and value) and then a Table Type on this structure to store multiple values, but how to make it unique?
Please help.
Regards,
Arpit.Hi,
In ABAP you can define table with KEY as unique.
You also have different types of table in SAP. (Standard, Hashed, Sorted).
You can refer to the link for details.
http://help.sap.com/erp2005_ehp_03/helpdata/EN/fc/eb36c8358411d1829f0000e829fbfe/frameset.htm
Regards,
Saurabh -
Time out parameters for ABAP and JAVA instance
Hello All,
We are looking for Time out parameters for our ABAP and JAVA instances.
As users are complaining that they are getting time out error
while they are trying to access Cprojects from Portal.
I was able to check/collect the ABAP instance parameters from SMICM Tcode.
Can anybody tell me which parameters we need to look for JAVA instance.
Thanks in advance.
Regards,
Amber Sjstart/shutdownTimeout
(jstartup/shutdown_timeout)
Specifies the shutdown timeout, i.e. the grace period for the AS Java instance to shut down before the Java process terminates itself. Unt is in Seconds. Default is 120
j2ee/ms/connectTimeout
(jstartup/wait_for_scs)
Specifies the timeout for the first connection to the message server. The AS Java instance fails to start if this timeout expires.Unt is in Seconds.Default is 60
j2ee/ms/reconnectTimeout
(jstartup/wait_for_reconnect)
Specifies the timeout for the reconnecting to the message server.The AS Java instance shuts down when this timeout expires.Unt is inSeconds.Default is 3600 (one hour)
Thanks -
Hi All,
I have connected following system with Solution Manager (Version 4.0) for System monitoring, Early Watch Alert, Central system administration.
1) Business Warehouse (SAP Net Weaver 2004s)
2) CRM (CRM 5.0)
3) 4.7 System (SAP R/3 Enterprise).
I am able to see all the database settings in Early Watch alert for all the systems.
Now I am doing BI Extraction through DSWP->(Solution)-> Solution Reporting-> BI Data Collection.
Abap program RDSWP_BI_ADMIN_TOOL is used for collecting the data.
And the data are populated to the following tables.
Tables No of records
DSWPBI_SYSTEM 7
DSWPBI_SYSDATA 79
DSWPBI_SERVER 1372
DSWPBI_PERF 40
DSWPBI_MODUL 7
DSWPBI_DB* 10
But when table is viewed through tcode SE11, data exists for records but the content of the table is not available.
The content is either empty or 0.
Example
For Table DSWPBI_MODUL, following are the various fields.
SM_CUST
SM_INST
SM_SID
SM_DATE
SM_BUNDL
SM_ENTR
SM_SPRAS
SM_MODUL
SM_MODCP
SM_MODDB
SM_APKEY
SM_APMOD
SM_DIAST
SM_CPUT
SM_DBT
SM_BOTHT
SM_TCODE
SM_SYSLD
SM_AVGLD
SM_BPTCO
SM_BPDATE
SM_BPSTPS
SM_BPAVG
SM_BPCPU
SM_BPDB
SM_BPRATI
SM_BPLIMY
SM_BPLIMR
Now the problem is with the content of the table.
Values are maintained for some of the fields like SM CUST
SM INST
SM SID
SM DATE
SM BUNDL
SM ENTR
SM SPRAS.
But for many of the fields like SM MODUL
SM APKEY
SM APMOD
SM DIAST
SM TCODE
SM BPTCO
SM BPDATE
SM BPSTPS
SM BPRATI
SM BPLIMY
SM BPLIMR
The value is either 0 or value is not maintained.
I think once a early watch report is generated, these fields should have some value.
Did anyone face this problem before?
Please help me in resolving this problem.
Sriram SHi,
The infopackage ran for full load and not for delta load.
I looked at the rsmo and at first glance everything looks fine. But when i look at the details tab i can see that the overall status shows as RED and it says
Overall Status: Errors occured: or : Missing Messages
I am not clear what this means. I dont see any other nodes in RED. Every node is in green except the top most node which is in RED and shows the above message.
Any idea what could be the problem? -
Transporting Problem - Tranformation Global Definitions Not Transporting
I have an issue trying to transport some Master Data characteristics. One example, 0PLANT, has routines in the transformation into 0PLANT_ATTR that call methods that are a part of generated code from when the transformation was activated. This ABAP program is not being picked up when I collect 0PLANT for transporting. The generated code appears in my local $TMP package. Since it is in the SAP namespace, I am unable to transport it manually or move it to a new package.
Is there some trick to collecting these ABAP programs that are used in transformation routines? Or are these all suppose to be created when you import the transport? If so, mine are not.
Thanksthe newly developed objects may he link with the previous developement..
like ztable ,zstructure,etc..
check and re trasport
Regards
Anbu B -
Dear forum users,
I've installed a Web AS Java using the "SAP Netweaver '04 SR 1 -> Java System -> Oracle -> Central system". Now I noticed that I can't logon using the SAP Gui, thus I can't use the Transport Management system. The problem is:
We wanted to build up a central system with a JDI, in which all work from decentral development computers is collected- both ABAP AND Java development! How can I set up somthing like that? Do I have to install an ABAP System with a Java add-on, so that both -the JDI and the STMS- is available?
Your suggestions will be appreciated!
Regards,
VolkerHi,
It does come with a Pure ABAP only feature too... as per the following
SAP Web Application Server comes with three installation options to match the customers need in mission critical environments.
· ABAP and Java
Complete infrastructure to develop and run ABAP and J2EE-based applications. This installation focuses on a seamless Java-ABAP integration. It is designed for productive use in large-scale environments.
· Java only
Complete infrastructure to develop and run J2EE-based applications. This installation is designed for productive use in large-scale environments.
· ABAP only
Complete infrastructure to develop and run ABAP-based applications. This installation is designed for productive use in large-scale environments.
· Java Developer Workplace
Complete infrastructure to develop and run J2EE based applications in a single-user system.
Please read this space.
http://help.sap.com/saphelp_nw04/helpdata/en/de/c8fe3e432fd861e10000000a114084/frameset.htm
Hope that helps.
Regards,
Siddhesh -
What happens in the background when a job is scheduled!!!
Hi,
Can anyone tell me what exactly happens in the background in SAP when a job is set to "Scheduled" ( sm37) .
Can v see the code executed in the background during the transtion from " Scheduled" state of a job to" Cancelled" to "Complete" state.
Its urgent,
Answers will rewarded,
regards,
RohanHi Rohan,
Jobs and job steps enable you to treat complex tasks as single units. That is, you can schedule several programs needed to complete a particular task as steps within a single job, with the advantage of the job being single logical container for all the steps needed to complete the task. You need to schedule or review only one background job in order to schedule or review any of the individual steps necessary for completing the task.
Assume that a particular data transfer with batch input requires that you start two programs, an external program to prepare the batch-input session and an internal program to process the session. Creating a job made up of two steps lets you handle the two programs as a single unit. Scheduling that one job schedules both programs. The results of each program's run can be seen in the job log.
Some background processing attributes apply to entire jobs and, therefore, to all job steps within a job. For example, the earliest possible start time for any job steps will be the start time for the job. Frequency of repetition, priority, and other global attributes also apply to the whole job.
To ensure that you can flexibly run individual programs, you can set important attributes individually for each job step, too. Each job step can:
have its own spool, or output, specifications
run under the authorizations of a separate user
use a different language
have its own runtime options (for programs external to the SAP System), such as handling of error output and synchronicity
In general, job steps run sequentially and synchronously in the order they're entered in a job: the first step starts, runs, and is completed, then the second step starts, and so on. The only exception is when you schedule an external program to run asynchronously. In this case, the background processing system starts the next job step without waiting for a return code from the external program. If the external program runs long enough, then the start of the next job step may overlap it.
Job steps run partially independently of each others status. That is, the abnormal termination of one job step does not roll back the work of a previously completed job step if this previous step was executing a commit. If any job step fails, however, then the entire job fails. No further job steps are carried out, and the job's status changes to Canceled.
There are two types of job steps:
An executable ABAP program
Only type 1, or executable, ABAP programs can be used as job steps. Module pools and function groups, which are collections of ABAP modules, are not allowed. The specifications required for an ABAP job step are:
ABAP program + Variant + Print and archiving parameters + Language
An external command or external program
This type of job step allows you to run programs outside the SAP System. External commands are predefined, authorization-protected commands for end users. External programs are unrestricted, directly entered commands reserved for system administrators.
The type of external command and external program is unrestricted, meaning that you can use either compiled programs or scripts. Such programs can be run on any computer that can be reached from the SAP System. Parameter passing to non-SAP programs is completely unrestricted except by the predefinition mechanism for external commands.
Output of non-SAP programs, particularly error messages, is included in the job's log file.
Specifications required for an external command or program are:
External command + Type of operating system + (Parameters) + Target host system
External program + Parameters + Target host system
Job Step Language
If your SAP System runs with an Arabic, Cyrillic, or Asian character set, then you may need to change the language specified in the standard background jobs listed above. Languages are assigned to jobs based on job steps. Be sure that the language specified in the job step definition in each of these jobs is set to English (EN).
This change is required because not all languages are available with all code pages. If the jobs specified language is not available, the job will not run.
<b>Reward pts if found usefull :)</b>
Regards
Sathish -
How to determine SLG1 Application Log Size
Hi, Can anyone tell me how we might be able to determine the size of our SLG1 Application Logs on our BW System?
We want to be sure they are not taking up too much space. If they are we'll purge with SLG2, and if not then we will keep them around.
Thanks!Hello,
system does writes the application log in to the database.
SAP_COLLECTOR_FOR_NONE_R3_STAT is designed to collect non ABAP Statistic Data in/for a central repository.
look service.sap.com/notes and search for SAP_COLLECTOR_FOR_NONE_R3_STAT
Hope it will hep you.
Regards, -
Dear Experts,
My client is asking us to implement the Personnel cost planning , Compensation Management. The main issue is we do not have Payroll in scope.
Could any one suggest me how should i guide them?? is it possible to to implement the PCP & compenstaion management with out Payroll???? if yes, what would be the solutions & reasons for this??
Kindly guide me, am bit confuse here....
Honestly yours
KumarHello friend!
You can use PCP if you have PA/PD modules implemented.
That´s because you can only collect data via PA/PD infotypes.
So, even if you don´t have SAP PY implemented, if you want do collect data from payroll you can create an infotype to receive the wagetypes via interface from the legacy system.
Also, PCP is usually used for budget management, so you will collect data from IT0008, IT0014, IT0015, IT0267, etc
PD infotypes are used for HeadCount (please read the documentation about this)
If you create an infotype, you also have to create an data collection method (ABAP) and place it in your PCP. Check SPRO for more information
Hope it helps
Regards
Marcos Matsumoto Hayashi
SAP HCM Consultant - Brazil -
SAP_COLLECTOR_FOR_PERFMONITOR error
I have a system DXD that is getting this error on SAP_COLLECTOR_FOR_PERFMONITOR:
ABAP/4 processor: EXPORT_TOO_MUCH_DATA
Has anyone had this problem?
ANy advice would be appreciated.Its a background job, mostly used for data collection for ABAP statistics records (DSR). It is by default scheduled for an hourly run. Check these two parameters stat/file (points to the instance specific data dir) and the parameter stat/maxfiles (max number of files before the first one is overwritten). See if the data directory has enough space or something.
Do you have any more info on the actual error?
Try checking your CCMS for alerts. Use transaction STAD or ST03N for further information on this report. -
Hello,
I have deployed the SMD Agent (SAP Agent) and the Wily IS Agent (CA agent) for my XDS managed system.
From "Solution Manager Diagnostics" tools, when I click on "Introscope WebView", I get the following information :
1. SAP HostAgent Process (SuperDomain)
- SAP HostAgent J982
- EM Host ....
2. SAP NetWeaver
- XDS_DVEMGS31_server0 (SuperDomain)
- EM Host
Question 01:
1. SAP HostAgent Process is the SMD Agent of XDS.
2. What about "SAP NetWeaver" ? Is it the content of "Wily IS JAVA Agent" ?
Question 02 :
From (1) "SAP HostAgent Process" and (2) "SAP NetWeaver", we get the same information, for example :
1. EM Host
2. Java Version
3. Launch Time
4. Virtual Machine
5. Agents Stats
6. Host
7. GC Heap ...
It seems that both agents are collecting the same data.
What it the SAP strategy in the future ?
Keep only one Agent (SMD) or keep both agents (SMD + Wily) ?
Thanks for your answer
Best regards
PCHi PC,
For Qusetion 1)-1 Host agents and wily bytecode agents are both IS agents. SAP host agent is one delivered with SMD Agent and is common for both ABAP and Java based systems.
2) Yes SAP Netweaver is the Byte code agent deployed through SDM and configured via SMD.
Question 2).
1) Only few datas will be common.IS byte code agents is specific for Java and has more details specific to the Java component installed. You still require an SMD agent for Configurations/Data collection in ABAP. so I reckon there will be two agents in future too. But there can be surprises ;).
Regards,
Jagan -
Hello,
I have a header and an item table which contains customer records in the header table and line items in the item table . A Customer has many billing document and hence there are a lot line items with the same material.
I want to use the collect statement to group all the materials and have one line item for one type of material and want to sum all the quantities of those materials and the price of the material.
suggest the best solution for the particular scenario.
thank you.Hi Rahul,
You can consider using ABAP Tree Control feature if you are planning to use ABAP Dialog Programing. It will be very elegant and will provide you with a nice UI. Have a look at the demo codes for the functionality.
Use the Transaction DWDM to get all the control examples. You can get more examples in SLIS Package.
If you try using ABAP Web Dynpro , then also you can design it in the way you want.
Hope this will help.
Thanks,
Samantak. -
Regarding COLLECT stmt usage in an ABAP Program.
Hi All,
Could anyone please explain if the COLLECT statement really hampers the performance of the program, to a large extent.
If it is so, please explain how the performance can be improved with out using the same.
Thanks & Regards,
Goutham.COLLECT allows you to create unique or summarized datasets. The system first tries to find a table entry corresponding to the table key. (See also Defining Keys for Internal Tables). The key values are taken either from the header line of the internal table itab, or from the explicitly-specified work area wa. The line type of itab must be flat - that is, it cannot itself contain any internal tables. All the components that do not belong to the key must be numeric types ( ABAP Numeric Types).
Notes
COLLECT allows you to create a unique or summarized dataset, and you should only use it when this is necessary. If neither of these characteristics are required, or where the nature of the table in the application means that it is impossible for duplicate entries to occur, you should use INSERT [wa INTO] TABLE itab instead of COLLECT. If you do need the table to be unique or summarized, COLLECT is the most efficient way to achieve it.
If you use COLLECT with a work area, the work area must be compatible with the line type of the internal table.
If you edit a standard table using COLLECT, you should only use the COLLECT or MODIFY ... TRANSPORTING f1 f2 ... statements (where none of f1, f2, ... may be in the key). Only then can you be sure that:
-The internal table actually is unique or summarized
-COLLECT runs efficiently. The check whether the dataset
already contains an entry with the same key has a constant
search time (hash procedure).
If you use any other table modification statements, the check for entries in the dataset with the same key can only run using a linear search (and will accordingly take longer). You can use the function module ABL_TABLE_HASH_STATE to test whether the COLLECT has a constant or linear search time for a given standard table.
Example
Summarized sales figures by company:
TYPES: BEGIN OF COMPANY,
NAME(20) TYPE C,
SALES TYPE I,
END OF COMPANY.
DATA: COMP TYPE COMPANY,
COMPTAB TYPE HASHED TABLE OF COMPANY
WITH UNIQUE KEY NAME.
COMP-NAME = 'Duck'. COMP-SALES = 10. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Tiger'. COMP-SALES = 20. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Duck'. COMP-SALES = 30. COLLECT COMP INTO COMPTAB.
Table COMPTAB now has the following contents:
NAME | SALES
Duck | 40
Tiger | 20 -
Collecting ABAP's into Transport Request
Guru's
I have about 100 ABAP Programs that start with ZC* these are all transported into Q system. But now due to technical reasons we are collecting Individual objects into different Transport requests to import into our Q & P systems respectively... Collecting Infoareas,DSO's,Cubes, and etc.,. had been quite easy.
Now the issue : Is their a possibility that I can collect all the ABAP's in one shot and these should include the dependencies (Tables;FuMo's) etc.,
A tip in this regard would be highly appreciated.
Regards
BVPKHi BVPK
I think there isn`t such a easy way you want to go.
But I`ve got a little work around to make it easier (I hope)
Call TA: SE03 --> select "search for requests --> press F8
Next screen, pres F8 again --> select/create a transport request -> press (Ctrl+F11) "include objects"
select "free choosen Objects" (sorry, it`s a german language system here) and enter.
--> now tyoe in the paket, your allready transported objects are assigned to --> F8
Now you got a stuctured list with all your components. You can mark (F6) every single entry you need and include all the marked in your selected transport request.
Hope this helps a little bit
Greets
TOM -
how to use collect statement.
Moderator Message: F1
Edited by: kishan P on Apr 8, 2011 3:49 PMHi Arun,
Use SELECT-OPTIONS with the addition NO-DISPLAY , then you can use it same as RANGES.
Refer to the sample code.
REPORT zztest_select.
DATA : g_matnr TYPE mara-matnr.
*-- NO-DISPLAY makes SELECT-OPTION not to be dispalyed and
*-- you can use the SELECT-OPTION as RANGES
SELECT-OPTIONS : s_matnr FOR g_matnr NO-DISPLAY.
CLEAR : s_matnr,
s_matnr[]
s_matnr-sign = 'I'.
s_matnr-option = 'BT'.
s_matnr-low = 'MATERIAL10'.
s_matnr-high = 'MATERIAL99'.
APPEND s_matnr.
<b>AS</b>
Maybe you are looking for
-
Plenty of free space, music not loading. HELP...
The iPod has successfully loaded about 12-31 songs when I first used it. It still has 7.21 GB of Free Space left. I need information about why the rest of my music is not loading to the iPod Nano 3g. My music, in total, is about 1 GB, give or take a
-
External Hard Drive Unavailable After Each Restart
Hi, everyone - I recently upgraded from a 2007 iMac to a 2012 iMac with a Fusion drive. I had two external drives on the old machine which are now connected to the new machine. Both are Seagate "Backup Desk" drives (2TB "Media" and 3TB "Time Machine"
-
Have set up a new mail box which was running through outlook express on my old windows machine. Although it is showing there and I am receiving some mail, not all of it is appearing in my inbox on my imac. I know this as, as a double check before I g
-
Hi Experts, Can you please tell me how these two mvt type 103 & 105 works.Please tell me some scenerio AR
-
Can i get a live wallpaper of the northern lights for my iphone 5
can i get a live wallpaper of the northern lights for my iphone 5