Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts

System Class for Establishing the Properties of Characters in ABAP

Here is the System Class for Establishing the Properties of Characters in ABAP.

The class CL_ABAP_CHAR_UTILITIES provides attributes and methods that concern attributes of individual characters. The components of this class are all static and public, the attributes are write-protected and are initialized in the class constructor.

Class for Time Formats and Conversion of Time Stamps in ABAP

These are two system classes that handle Conversion of Time Stamps and time formats in ABAP programs.

  • The class CL_ABAP_TSTMP is used for calculating time stamps.
  • The class CL_ABAP_TIMEFM is available for establishing time formats and converting between different time formats.

System Class for internal tables in ABAP

The CL_ABAP_ITAB_UTILITIES class contains methods with which individual or all secondary table keys of an internal table can be explicitly updated. Otherwise the update takes place as a delayed or lazy update.System class CL_ABAP_ITAB_UTILITIES is used for speeding the internal table updation.

Mathematical Operation classes in ABAP

Here is some System classes and its methods that handle Mathematical Operations in ABAP.

Class CL_ABAP_MATH contains methods and constants for operations with floating point numbers.

Methods and operations with decimal floating point numbers

  • Method GET_SCALE returns the scaling of a decimal floating point number.
  • Method GET_NUMBER_OF_DIGITS returns the precision of a decimal floating point number.
  • Method NORMALIZE returns a normalized floating point number. That is, the scaling and precision of an input value are changed so that the mantissa does not have trailing zeros.
  • Method GET_SCALE_NORMALIZED returns the scaling of a normalized decimal floating point number. If the input value has a fractional portion, the return value is the number of decimal places without trailing zeros.
  • Method GET_MAX_DB_VALUE returns the maximum value of a number of type DF16_DEC or DF34_DEC in the database.
  • Method GET_DB_LENGTH_DECS returns the length and number of decimal places of a number of the type DF16_DEC or DF34_DEC in the database.

Class CL_ABAP_RANDOM calls the pseudo random number generator for various numeric types.

  • CL_ABAP_RANDOM_INT for type i
  • CL_ABAP_RANDOM_FLOAT for type f
  • CL_ABAP_RANDOM_PACKED for type p
  • CL_ABAP_RANDOM_PACKED_DEC1 to CL_ABAP_RANDOM_PACKED_DEC14 for type p with 1 to 14 decimal places.

Classes for Data Clusters in ABAP

Subclasses of the abstract system class CL_ABAP_EXPIMP are used for handling Data clusters in ABAP.using these classes we can access/ delete data clusters in the individual storage media.

  • CL_ABAP_EXPIMP_MEM
  • CL_ABAP_EXPIMP_SHMEM
  • CL_ABAP_EXPIMP_SHBUF
  • CL_ABAP_EXPIMP_DB
  • CL_ABAP_EXPIMP_CONV

Which class is using for file interface in ABAP ?

The static methods of the class CL_ABAP_FILE_UTILITIES provide information about files on the application server and this class is using for dealing with file interface in ABAP

Which class is using for Getting the Transaction Status in ABAP

The class CL_SYSTEM_TRANSACTION_STATE contains methods that return the status of the current SAP LUW and this class is using for Getting the Transaction Status in ABAP.

Classes for Compressing Data in ABAP

These classes offer a range of methods that enable text in text fields or text strings, or binary data in byte fields or byte strings to be compressed or decompressed using GZIP.

  • CL_ABAP_GZIP
  • CL_ABAP_GZIP_BINARY_STREAM
  • CL_ABAP_GZIP_TEXT_STREAM
  • CL_ABAP_UNGZIP_BINARY_STREAM
  • CL_ABAP_UNGZIP_TEXT_STREAM

Some more advanced system classes in ABAP

  • The static method GET_VALUES from the CL_ABAP_GEN_LIMITS class returns the generation limits for an ABAP program
  • CL_ABAP_MEMORY_UTILITIES is using for Memory Analyses in ABAP.
  • The static methods CREATE_HR_TIMER and CREATE_LR_TIMER of class CL_ABAP_RUNTIME can be used to generate objects for runtime measurements
  • The methods of class CL_SYSTEM_UUID create UUIDs in different formats, such as 16-digit byte-type UUIDs, 22-digit character-type UUIDs with upper and lower case letters, and 32-digit character-type UUIDs in hexadecimal.
  • Using the class CL_ABAP_UNIT_ASSERT you can check the test acceptance in test methods and evalute them with ABAP Unit.

List of System Fields in ABAP

These are the list of some the important System fields in ABAP and its details.

System Fields Type System Field details
sy-abcde c(26) This Transaction code Contains the Latin alphabet. Can be used to access individual letters directly by specifying the offset/length, regardless of the code page.
sy-batch c(1) This Transaction code Set to “X” in an ABAP program that runs in the background, otherwise initial.
sy-binpt c(1) This Transaction code Set to “X” during processing of batch input sessions, and in ABAP programs called using CALL TRANSACTION USING. Otherwise initial.
sy-calld c(1) This Transaction code Contains a blank character in the first program in a call sequence, otherwise contains the value “X”. Is set to “X” after calls using CALL TRANSACTION, CALL DIALOG, or SUBMIT … AND RETURN. Empty if the program was started using LEAVE TO TRANSACTION or a transaction from the screen. A call using SUBMIT (without AND RETURN) assumes the value of the calling program.
sy-callr c(8) This Transaction code used When printing lists, contains a value that displays where printing was started – for example, NEW-PAGE for program-controlled printing, or RSDBRUNT for printing from the selection screen.
sy-colno i This Transaction code return Current position during creation of a list in the list buffer. Counting begins at 1. In non- Unicode systems, this position also corresponds to the column in the displayed list. In Unicode systems, this is only guaranteed for the lower and upper output limits applicable to each output, as one character may take up more columns in the list than positions in the list buffer.
sy-cpage i This Transaction code return Page number of the page displayed at the top of the list for which a list event was triggered. Counting begins at 1.
sy-cprog c(40) In procedures called externally, the name of the calling program, otherwise the name of the current program. If a procedure called externally calls another external procedure, sy-cprog contains the name of the framework program, and is not set to the name of the framework program of the subsequent calling program.
sy-cucol i This Transaction code return Horizontal cursor position in the display on a dynpro. Counting begins at column 2.
sy-curow i This Transaction code return Vertical cursor position on the screen display of a screen. Counting begins at line 1.
sy-datar c(1) At PAI, contains “X” if at least one input field of a screen has been changed by a user or by further data transfer, otherwise initial.
sy-datlo d Local date of the user – for example, “19990723″. Can be set using GET TIME.
sy-datum d This Transaction code return System date (local date of the AS ABAP). Can be set using GET TIME.
sy-dayst c(1) “X” during summertime, otherwise initial.
sy-dbcnt i SQL statements set the content of sy-dbcnt to the number of processed table lines.
sy-dbnam c(20) In executable programs, the linked logical database.
sy-dbsys c(10) Central database system – for example, “ORACLE”, “INFORMIX”.
sy-dyngr c(4) Screen group of the current screen. In the Screen Painter, several screens can be assigned to a common screen group, which can be used, for example, for making modifications to all screens in the group at once.
sy-dynnr c(4) This Transaction code return Number of the current screen. During selection screen processing, this is the current selection screen. During list processing, the number of the subscreen container. During processing of a subscreen dynpro (including in tabstrips), this screen number.
sy-fdayw b Factory calendar weekday, Monday = 1, …, Friday = 5.
sy-fdpos i Found location for certain searches in character-like and byte-like data objects.
sy-host c(32) Network name of the host on which the current application server is instantiated, for example “KSAP0001″, “HS01234″.
sy-index i This Transaction code return Loop index. In DO and WHILE loops, contains the number of the loop passes including the current pass.
sy-langu c(1) Single-character language key – for example, “D”, “E”, “F” – for the current text environment. Set according to the logon language of the user or by using the statement SET LOCALE.
sy-ldbpg c(40) In executable programs, the database program of the linked logical database.
sy-lilli i This Transaction code return List line for which a list event was triggered. Counting begins at 1 and includes the page header.
sy-linct i This Transaction code return Page length of the current list during list creation. sy-linct is 0 for a standard list of any length, and has a value that is not 0 for lists with a defined page length.
sy-linno i This Transaction code return Current list line during list creation. Counting begins at 1 and includes the page header.
sy-linsz i Line width of the current list in the list buffer during list creation.
sy-lisel c(255) Content of the list line in the list buffer, on which the cursor was positioned while a list event was triggered (restricted to the first 255 lines).
sy-listi i List level of the list for which a list event was triggered.
sy-loopc i Number of lines currently displayed in a table control.
sy-lsind i List level of the list that is currently being created (basic list: 0, details lists: greater than 0). For every interactive list event, sy-lsind is automatically increased by an increment of 1. sy-lsind can only be changed in ABAP programs for navigating between details lists.
sy-macol i When printing lists, contains the number of columns on the left edge.
sy-mandt c(3) Client identifier with which the user has logged on – for example, “401″, “800″.
sy-marow i When printing lists, contains the number of lines on the top margin.
sy-modno i Indexing of external sessions. Contains the value 0 in the first session. In new sessions that are opened using the Create Session function or by calling a transaction with /o in the command field of the standard toolbar, this value is increased by 1.
sy-msgid c(20) After the statement MESSAGE, contains the message class.
sy-msgno n(3) After the statement MESSAGE, contains the message number.
sy-msgty c(1) After the statement MESSAGE, contains the message type.
sy-msgv1 … sy-msgv4 c(50) After the statement MESSAGE, contain the contents of the fields that were used as placeholders in the message.
sy-opsys c(10) Operating system of the current application server – for example, “SOLARIS”, “HP-UX”.
sy-pagno i Current page in list creation.
sy-pfkey c(20) GUI status of the current dynpro.
sy-prdsn c(6) When printing lists, contains the name of the spool file.
sy-repid c(40) Name of the current ABAP program. For procedures called externally, name of the framework program of the procedure. If sy-repid is transferred as an actual parameter to an external procedure, the formal parameter is set to the name of the caller.
sy-saprl c(4) Release status of the AS ABAP, e.g. “46D”, “610″.
sy-scols i Number of columns of the current screen.
sy-slset c(14) Variant that was used for filling a selection screen. The associated program name is in sy-cprog.
sy-spono n(10) When printing lists, contains the name of the spool number.
sy-srows i Number of lines of the current screen.
sy-staco i Number of the first column displayed in the list for which a list event has been triggered. Counting begins at 1.
sy-staro i Number of the list line displayed at the top of the page at the top of the list, for which a list event was triggered. Counting begins at 1 and does not include the page header.
sy-stepl i Index of the current line in a table control. This is set for every loop pass.
sy-subrc i Return value that is set by many ABAP statements. In general, the value 0 means that the statement was executed with no problems. Depending on which statement was used to set sy-subrc, the cause of any errors can be derived from the corresponding value. The content of sy-subrc is not defined after statements for which the setting of sy-subrc is not documented explicitly.
sy-sysid c(8) Name of the AS ABAP, for example “S01″, “K99″..
sy-tabix i Line number in the table index of an internal table. Contains the last line accessed with a primary or secondary table index. Is set to 0 when accessed with a hash algorithm.
sy-tcode c(20) Name of the current transaction code. Initial in background processing unless a transaction was called during background processing.
sy-tfill i In the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, sy-tfill is filled with the number of lines in the internal table that has been addressed.
sy-timlo t Local time of the user, for example “152557″. Can be set using GET TIME.
sy-title c(70) Text that appears in the title bar of the screen.
sy-tleng i In the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, sy-tleng is filled with the line size of the internal table that is being addressed.
sy-tvar0 … sy-tvar9 c(20) These system fields can be assigned values in the program. At the event TOP-OF-PAGE, the content of sy-tvar0 to sy-tvar9 replaces the placeholders “&0″ to “&9″ in the list and column headers of the text elements of the program.
sy-tzone i Time difference to the UTC reference time in seconds – for example, “3600″, “10800″.
sy-ucomm c(70) Function code that triggered the event PAI.
sy-uline c(255) Contains a horizontal line of length 255 for displaying in lists.
sy-uname c(12) User’s logon name – for example, “KELLERH”.
sy-uzeit t System time (local time of the AS ABAP). Can be set using GET TIME.
sy-vline c(1) Contains a vertical line (|) for displaying in lists.
sy-wtitl c(1) In the statements REPORT, PROGRAM, and FUNCTION-POOL, set to “N” if the addition NO STANDARD PAGE HEADING is used, otherwise initial.
sy-zonlo c(6) Time zone of the user – for example, “CET”, “PST”.

Calling an Executable Program Using ABAP

Today I want to teach you how to call an executable program using ABAP, the function that we will be using is “GUI_RUN”. This function has 2 main parameters, COMMAND and PARAMETER. The COMMAND is used to pass the executable program’s name and the PARAMETER can be used to pass the file name (if any)

If you only supply the COMMAND parameter then it will only call the executable program, but if you want to call a specific file e.g. BOOK1.XLS then you should supply the PARAMETER with the file name.

Here’s the ABAP sample code to call an EXCEL workbook.

01.REPORT Z_Calling_EXE_Program.
02.
03.CALL FUNCTION 'GUI_RUN'
04. EXPORTING
05. COMMAND = 'EXCEL.EXE'
06. PARAMETER = 'C:UsersUserDocumentsBOOK1.XLS'.
07.* CD = '
08.* IMPORTING
09.* RETURNCODE = .

When you run the program, make sure that you already created the Excel workbook in the destinated folder. You can also change the COMMAND parameter into another type of executable program, e.g. NOTEPAD.EXE, WORD.EXE, etc.

You can also call a web browser, e.g. FIREFOX and immediately open certain website. e.g. www.google.com.

1.CALL FUNCTION 'GUI_RUN'
2. EXPORTING
3. COMMAND = 'FIREFOX.EXE'
4. PARAMETER = 'GOOGLE.COM'.
5.* CD = '
6.* IMPORTING
7.* RETURNCODE = .

How To Find User Exits in SD Module Using SPRO

In today’s tutorial I want to show you how to find User Exits in SD module using SPRO tcode.

1. Execute TCODE SPRO. Click on the “SAP Reference IMG” button.

spro02-01

2. Now expand, Sales and Distribution -> System Modifications -> User Exits. There you will find a list of available user exits for various processes.

spro02-02

3. Click on the Paper icon to show the User Exits list. In this example I want to show all the user exits for Price determination, once I click the “Paper” icon, the pop up window will show you the user exits list.

spro02-03

SAP ERP Upgrades – 4 Scenarios To Help You Decide

Today I want to share some scenarios that could be the sign to upgrade your SAP ERP system.

1. When you have been using your ERP for more than 5 years old, then it might be a sign to upgrade it. Most experts suggest that in this year span, you need to reevaluate your ERP system, whether or not it’s still has the power to efficiently run your business.

2. Another sign to upgrade your ERP is when you find it very difficult to do system integration. When a company become larger and its business expanding, sometimes buying a third party software in unavoidable, and this will require a system integration with your existing ERP system. The most important question you need to ask is whether or not it’s time to upgrade your ERP system to reduce maintenance work and integration cost?. The newest ERP system is now built based on a service oriented architecture (SOA) that could help you reduce maintenance and integration cost.

3. You should upgrade your ERP system when you have missing some features that could help you run business effectively, for example when you have create a new business process that involving sending order electronically then you would need SAP ERP web functionality, and that will be a sign to upgrade your system because of lacking functionality.

4. When you’re relying on the ERP knowledge to run your business, e.g. an ERP consultant, then it is very important to keep the latest upgrade in all your ERP systems, because that will determine your success in the ERP competing market. By upgrading the system you will keep your knowledge and skill updated and ready to compete in the open market.

There you have it, 4 main scenarios that could help you decide whether or not you need to do the upgrading. If your business fall into one or several of these scenarios then it’s a good sign that you need to upgrade your SAP ERP system.

How To Migrate SmartForms to Adobe Interactive Forms

In this tutorial you will learn how to migrate your existing SmartForms into a PDF-based form in Adobe interactive forms.

Bear in mind, that if you’re using graphics in the SmartForms, be sure to migrate them first into MIME repository.

Now follow these steps to migrate your SmartForms into Adobe Interactive Form.

1. Execute TCODE SmartForms.
2. Select Utilities -> Migration -> Interactive Form -> Export.

msf04-01

3. Enter the name of the SmartForms you want to migrate and the name of the PDF-based target form and also the target interface. By default, the Form target and the interface name are the same but you can change this and use a different name. Press enter to continue.

msf04-02

4. Now you will see the settings dialog box, just leave it as default or change the setting accordingly. You can press F1 on the setting option that you don’t understand to show more detail information. Click continue or enter to proceed.

msf04-03

5. Next you will be prompted with a “Create Object Entry” dialog box, you could include the program into a package and get the tr number and tranport it into the destination client.

ABAP Debugging Tutorial – BreakPoint At Function Name

Debugging is a daily job for ABAPers, and SAP has an ABAP debugger program that is very easy to use and has a lot of great features to help ABAPer to debug any program.

In this ABAP Debugging Tutorial you will learn how to set a breakpoint on a function module name during run time.

1. Execute any tcode that will run any program, e.g. ZS1234_CCODE
2. Now execute /h tcode, to switch debugger on.

adp05-01

3. Now after execute the program as usual (F8), you will be entering the debugging mode. Now choose Breakpoints > Breakpoint at > Breakpoint at function module

adp05-02

4. Enter the name of the function module you want to debug, click enter to set the breakpoints.

adp05-03

How To Save Internal Table Into Excel in Run time

In this tutorial you will learn how to save your internal table data into Excel in run time.

1. Display the Internal table content in debug mode.

2. Right click any where in the content and choose Save to Local file.

dit06-01

3. Choose “Spreadsheet” option and click enter.

dit06-02

4. Choose the folder to save the file.

dit06-03

How To Show Progress Bar Using ABAP

Here’s a sample code to show / display progress bar using ABAP. We will be using ‘SAPGUI_PROGRESS_INDICATOR’ function module.

01.REPORT Z_PROGRESS_BAR_DISPLAY.
02.
03.DATA: progress_txt TYPE c LENGTH 5.
04.
05.DO 100 TIMES.
06.
07. "Every progress will wait until 0.50 seconds
08.
09. WAIT UP TO '0.50' SECONDS.
10.
11. progress_txt(3) = sy-index.
12. progress_txt+3 = '%'.
13.
14. CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
15. EXPORTING
16. percentage = sy-index
17. text = progress_txt.
18.
19.ENDDO.

Using Variants As Default Values Using ABAP

If you need to use variant values as the default values in your selection screen, then you can achieve this by using the “RS_SUPPORT_SELECTIONS” function module.

All you need to do is supply the variant name and it will display the value automatically during the INITIALIZATION event.

Here’s the ABAP SAMPLE CODE.

01.INITIALIZATION.
02.
03. data: tp_subrc like sy-subrc.
04. data: tp_repid like rsvar-report.
05. data: tp_variant like rsvar-variant.
06.
07. tp_repid = sy-repid.
08. clear tp_variant.
09. tp_variant = 'Your Variant Name'.
10.
11. "Check if the variant is exist.
12.
13. call function 'RS_VARIANT_EXISTS'
14. exporting
15. report = tp_repid
16. variant = tp_variant
17. importing
18. r_c = tp_subrc
19. exceptions
20. others = 9.
21.
22. if sy-subrc = 0.
23.
24. call function 'RS_SUPPORT_SELECTIONS'
25. exporting
26. report = tp_repid
27. variant = tp_variant
28. exceptions
29. variant_not_existent = 01
30. variant_obsolete = 02.
31.
32. endif.

Once you run the report program (F8) you will see the selection screen are populated by the variant values.

IDOC Creation (Step by Step)

This Idoc Creation Procedure (Step by step Guide) will teach you with all the instructions on creation of Inbound and Outbound IDOC with screen shots for better understanding.