Oct 6, 2015

SAP ABAP FAQs- Part 2

Q: Steps to create Enhancement Spot/ BADI

1. Go to se18.
2. Enter the name enhancement spot and click create.
3. On next screen click on create new BADI.
4. Once the BADI is created then expand the tree on the left side.
5. Then double click on interface and give the name of the interface.
6. On the next screen it will ask for interface methods and its level ,that is it static or instance ?
7. Go to se19, and then click on enhancement spot ,enter the name of enhacement spot created above and click on  implement.
8. On next pop up give the name of enhancement implementation.
9. On next screen give the name of BADI implementation and its implementation class and also BADI definition just created above and save.
10. Now back to se18 and there activate both enhancement spot and BADI implementaion.And see both BADI interface and implementation.

Q: How to find BADI/Exit calls in any transaction?

Sometimes it is not so easy to find a BADI method or user exit to implement at an exact momment of the execution of a program. Here is one of the ways that can be used to spot which BADI method or user exit should be implemented.
1. Enter SE24;
2. Enter the class name CL_EXITHANDLER;
3. Double-click the method GET_INSTANCE;
5. Set a break-point at command line CASE sy-subrc (near line 25);
6. Execute the transaction you want to analyse; It will stop at the break-point you have just set on class CL_EXITHANDLER when it finds any BADI method/Exit call.
7. On debug screen, type the field name exit_name. This field contains the BADI method/Exit name which is being called in the program on that momment.
8. Press F8 to see the next calls.

Q: How can I solve dump due to insufficient memory (SELECT)?

I am using a SELECT query on a database table. Since the number of records in the table is very large,
the program dumps due to insufficient memory. How can I solve this?

In this case you could use the PACKAGE SIZE addition in the SELECT query to process in limited amount of data,
thus avoiding the memory overloads.
Ex: 
SELECT *
FROM 
INTO TABLE itab
PACKAGE SIZE .
IF sy-subrc EQ 0.
\*" Process the n records
ENDIF.
ENDSELECT.

Q: How can I convert numerals into the corresponding text?

Use the Function Module SPELL_AMOUNT to convert the integer into text.
Ex: 
DATA v_int TYPE i VALUE '1000'.
DATA words LIKE SPELL.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = v_int
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = words.
WRITE words-word.

Q: How to convert a date to internal or external format?
Use the functions modules CONVERT_DATE_TO_EXTERNAL or CONVERT_DATE_TO_INTERNAL
to convert the date. When converting to external format, the date format from the user's user profile will be used.
When converting to internal format, the result will be in YYYYMMDD format.
Q: What are indexes?
 Indexes are described as a copy of a database table reduced to specific fields. This data exists in sorted form. This sorting form ease fast access to the field of the tables. In order that other fields are also read, a pointer to the associated record of the actual table are included in the index. The indexes are activated along with the table and are created automatically with it in the database.

INDEXES are helpful for accessing data from the database tables.
PRIMARY INDEX: This is automatically generated the movement we create a database table.It is only for the key fields in the table.
SECONDARY INDEX : This is given in addition to the Primary Index already existing for the table ,so as to improve the data retrieval consistently, so as a result the performance is also increased.Secondary Index is also helpful in reducing the load on the Database.
Q: Difference between XVBAP and YVBAP in MV45AFZZ Include
YVBAP - Contains the line item data from Database VBAP
XVBAP - Contains the Current changes on the Line Items

Q:ABAP - how to read locked infotype records in HR ?

In HR master data maintenance, you can lock individual infotype datarecords. These data records are normally ignored during evaluationsusing PNPCE. If you set the PNP-SW-IGNORELOCKEDRECORDS switch to N (atthe INITIALIZATION or START-OF-SELECTION events), the report can howeverinstruct PNPCE to read locked data records too. Authorization Check: PNP_SW_SKIP_PERNR, PNP_GET_AUTH_SKIPPED_PERNRS.

INITIALIZATION.

pnp-sw-ignorelockedrecords = 'N'.

Q: How to test a RFC connection in Production?

In Production environment generally consultants do not have access to SM59. In that case use program RSRFCPIN to test the RFC destination. Most consultants must have SA38 authorization. 

Q: Enhancement section & Enhancement point 

Enhancement Point -
If you have written code using enhancement point your custom code will be executed along with the standard code.

Enhancement Section -

If you have written code using enhancement section, only your custom code will be executed replacing standard code. standard code will not be executed.

Q: What is 'Log data Changes' in Z-Table creation?


Table log history in SCU3 if the Table is logged for changes..> Technical settings-->Log data changes.

Q: Prerequisites for "For All Entries" ?

1.Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.

2.If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.

3.If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.

Q: What are INDEX in a Table?

INDEXES are helpful for accessing data from the database tables.

PRIMARY INDEX: This is automatically generated the movement we create a database table.It is only for the key fields in the table.

SECONDARY INDEX : This is given in addition to the Primary Index already existing for the table ,so as to improve the data retrieval consistently, so as a result the performance is also increased.Secondary Index is also helpful in reducing the load on the Database.


Q: Advantages of Domains and Data Elements :
a)      Re-usability

b)      Foreign Key Relationships Can be maintained Because the Foreign Key Fields and Check table fields should have the Same Domain.

Q: Which is the better - JOINS or SELECT... FOR ALL ENTRIES...?

In most scenarios INNER JOIN performs better than FOR ALL ENTRIES, and should be used first. Only if there are performance issues should FOR ALL ENTRIES be considered, and careful measurements taken before and after to validate whether there really are performance gains. 
The effect of FOR ALL ENTRIES needs to be observed first by running a test program and analyzing SQL trace. Certain options set by BASIS can cause FOR ALL ENTRIES to execute as an 'OR' condition. This means if the table being used FOR ALL ENTRIES has 3 records, SQL Trace will show 3 SQL's getting executed. In such a case using FOR ALL ENTRIES is useless. However of the SQL Trace shows 1 SQL statement it's beneficial since in this case FOR ALL ENTRIES is actually getting executed as an IN List.
JOINS are recommended over FOR ALL ENTRIES. There is no real limit to the number of tables that can be joined; however greater complexity can make maintenance harder, and if there are problems with the join, make it harder to resolve them. If the JOIN is being made on fields which are key fields in both the tables, it reduced program overhead and increases performance. 

In some scenarios, you are presented with an internal table. In these situations, you may have no choice but to use FOR ALL ENTRIES.



Q: FAQ on OOP ABAP
http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=281773094

Aug 27, 2015

Copying test IDocs from another system

There are times in a project when you have to copy an existing solution from one system to another. Or you develop a solution in a sandbox instance that has no connectivity to other systems in the landscape. Or even you simply develop a scenario similar to the one you have already implemented in the past, and want to reuse previous experiences. In all these situations, finally, with your developments ready, you want to start testing and realize that you need some test message for that purpose. With Proxy interfaces your task is easier, because you can copy-paste an XML message directly into the testing tool. But what about IDoc-based connections?

Let us assume a model situation. You have system A, where certain IDoc inbound solution is up and running, and system B, where you are expected to develop a similar one, in particular, based on the same IDoc message. System B is a sandbox, and therefore is not (yet) connected to any other tools over RFC (i.e. PI or system A). You just finished your developments and now want to test, but have no test IDoc message for that purpose. What you can do is create a test IDoc with the test tool (t-code WE19), but this can be extremely time consuming, especially with IDocs with multiple segments, complex structures or mass loads. So why not just copy an example IDoc from system A? With no RFC connection (and ALE settings) between systems A and B it might not be that simple, but still you can use this small trick to save yourself from a few minutes or hours spent on writing data into IDoc.

At high level, the process is as follows:
IDoc in system A -> file in AL11 of system A -> file on your desktop -> file in AL11 of system B -> IDoc in system B -> your highly desirable test 
Let’s have a closer look at each of those steps.

Step 1. System A. Export IDoc to file in AL11
There are two possible ways to export an IDoc to a file. You could create an IDoc port of type File (WE21), then outbound your IDoc to that port to have it written to a file. But you can also use a little trick that will help you avoid doing any ALE configuration. For that purpose, enter transaction WE19, put your source IDoc number, choose the “Inbound file” option, type a file path and name (on SAP server!), make sure to unmark the “Start IDoc inbound processing of file immediately” and confirm. As a result, the file will be written to a file on SAP server.
  It is important to notice that this action will result in another IDoc being created in the system, in status 68 “Error – no further processing” “Pattern IDoc written to database. Not defined for processing”.


Step 2. System A. Copy file from SAP server to your local station
In most cases, you can do this using transaction CG3Y:

However, this transaction is not available in some systems like PI or CRM. In such case, you can execute Function Module ARCHIVFILE_SERVER_TO_CLIENT instead:


Step 3. System B. Upload file from your local station to server
Similar to previous step, you can use transaction CG3Z (whenever available) or Function Module ARCHIVFILE_CLIENT_TO_SERVER.

 Step 4. System B. Process IDoc from file
The final step is simply to process your IDoc from file, using standard transaction WE19 and pointing your newly created file as a payload source.


 Ref:

Jun 15, 2015

Reprocess or Delete an Idoc

Using Transaction BD87, you can reprocess or delete an Idoc that is in error.  

How to reprocess an Idoc:

 1. Go to transaction BD87
 2. Enter Idoc number, and check that the dates are correct
 3. Click the Execute button or press F8
 4. To reprocess, select the Idoc status in the "IDOC in inbound processing" tree.
 5. Click the Process button
 6. The following screen will give the status of the IDOC and wheter it processed sucessfully

How to flag an Idoc to be deleted:

 1. Go to transaction BD87
 2. Enter Idoc number, and check that the dates are correct
 3. Click the Execute button or press F8
 4. To delete, select the Idoc status in the tree and click EDIT -> RESTRICT AND PROCESS
 5. Un-check the Bkgd Processing checkbox.
 6. Click the Execute button
 7. Click the Execute button
 8. Click the Delete Flag button

Apr 17, 2015

IDoc Statuses

IDoc statuses


Table TEDS1 contains list of all status codes.
Starting statuses may be: 01 (outbound), 50 (inbound), 42 (outbound test), 74 (inbound test)
Status number
Type of status
Status description
Next success status
Next error status
Error reason
Solution to error
01
Success
Outbound IDoc created
30
29


02
Error
Error passing data to port


Correct the error and Execute RSEOUT00 program again
03
Success
Outbound IDoc successfully sent to port
None, 32


04
Error
within control information on EDI subsystem



05
Error
during translation



12
Success
Dispatch OK

Changed from status 03 by BD75 transaction (see below)

25
Success
Processing outbound IDoc despite syntax errors



26
Error
during syntax check of outbound IDoc

Missing mandatory segment for example
You may edit the IDoc or force it to be processed
29
Error
ALE service (for example
29, 31


30
Success
Outbound IDoc ready for dispatch (ALE service)
03
02
Partner profile customized to not run
Execute RSEOUT00 program
31
Error
no further processing
32
Success
Outbound IDoc was edited

There was a manual update of the IDoc in SAP tables, the original was saved to a new IDoc with status 33

33
Success
Original of an IDoc which was edited. It is not possible to post this IDoc
None
None
Backup of another IDoc manually updated, see status 32

35
Success
IDoc reloaded from archive. Can't be processed
37
Error
Erroneous control record (for example, "reference" field should be blank for outbound IDocs)
None, 37


42
Success
Outbound IDoc manually created by WE19 test tool
01
37


50
Success
Inbound IDoc created
64
65


51
Error
inbound IDoc data contains errors
53, 64
51, 66, 68, 69
Error triggered by SAP application, incorrect values in the IDoc data
Ask functional people, modify erroneous values in the IDoc (WE02 for example) and run it again using BD87
53
Success
inbound IDoc posted
None, 53


56
Error
IDoc with errors added (You should never see this error code)
50, 51, 56, 62, 68


60
Error
syntax check of inbound IDoc
56, 61, 62


61
Error
Processing inbound IDoc despite syntax error
64


62
Success
inbound IDoc passed to application
53
51

63
Error
passing IDoc to application



64
Success
Inbound IDoc ready to be passed to application
62
51, 60, 63, 68, 69

execute BD20 transaction (RBDAPP01 program)
65
Error
ALE service - incorrect partner profiles
64, 65


66
Waiting
Waiting for predecessor IDoc (Serialization)

51
68
Success
no further processing
68
None
The IDoc was created using inbound test tool (WE19) and written to file to do file inbound test. Another IDoc is created if immediate processing is chosen

69
Success
IDoc was edited
64
51, 68, 69
There was a manual update of the IDoc in SAP tables, the original was saved to a new IDoc with status 70

70
Success
Original of an IDoc which was edited. It is not possible to post this IDoc
None
None
Backup of another IDoc manually updated, see status 69

71
Success
Inbound IDoc reloaded from archive. Can't be processed
74
Success
Inbound IDoc manually created by WE19 test tool
50, 56


How to change Transport request from Released to Modifiable

Step 1: Go to SE38 – Execute Program RDDIT076.  Step 2: Give your released requests number and execute again. Step 3: After executing, yo...