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

Monday, December 4, 2023

SAP giới thiệu mã hỗ trợ AI trong ngôn ngữ ABAP riêng của mình

SAP đã ra mắt một loạt tính năng mã hỗ trợ AI trong môi trường phát triển ứng dụng dựa trên đám mây của mình, đồng thời tham gia vào danh sách các nhà cung cấp khác cũng thông báo về các tính năng tương tự. Tuy nhiên, các nhà phát triển và các chuyên gia cho biết họ lo ngại rằng công nghệ tương tự có thể không được áp dụng cho các hệ thống on-prem mà họ đang làm việc để di chuyển và nâng cấp lên đám mây.

SAP giới thiệu hai hình thức mã hỗ trợ AI. Đầu tiên là SAP Build Code, một tiện ích mở rộng của môi trường low-code SAP Build trong Nền tảng Công nghệ Doanh nghiệp (BTP) dựa trên đám mây. Sử dụng trợ lý AI Joule, hệ thống này được thiết kế để giúp tạo mô hình dữ liệu, logic ứng dụng và kịch bản kiểm thử bằng JavaScript và Java. Trong khi đó, ABAP Cloud Environment, công cụ phát triển dựa trên đám mây cho ngôn ngữ đặc thù của SAP, cũng đang nhận được mã hỗ trợ từ GenAI. Cả hai tính năng này đang trong giai đoạn xem trước và dự kiến ​​được ra mắt vào năm tới.


ABAP Cloud Environment thay thế Embedded Steampunk, một công cụ còn được gọi là SAP S/4HANA Cloud ABAP Environment, năm ngoái, như một cách củng cố thêm danh tiếng của SAP trước các các quy ước đặt tên rắc rối. SAP vừa kỷ niệm sinh nhật lần thứ 40 của ngôn ngữ ABAP của mình.


Juergen Mueller, giám đốc công nghệ của SAP, cho biết SAP Build Code mang lại trải nghiệm phát triển đơn giản hóa thông qua một sảnh đợi thống nhất trong BTP. "Điều này làm cho việc hợp tác giữa các nhà phát triển công dân (citizen developers) và các nhà phát triển chuyên nghiệp trở nên rất dễ dàng. Chúng tôi đang áp dụng khả năng tạo ra tự động thông qua trí tuệ nhân tạo để tăng năng suất của nhà phát triển", ông nói.


Ngoài Build Code, SAP cũng giới thiệu Hướng dẫn cho nhà phát triển SAP BTP và HLV SAP Build. Build Code và môi trường ABAP SAP BTP có thể được sử dụng cùng nhau để tạo ứng dụng và tiện ích mở rộng trong S/4HANA. "Việc làm điều đó đương nhiên là rất quan trọng trong bối cảnh chiến lược nhân tố lõi nhiệt tâm với S/4HANA", Juergen Mueller nói.


SAP khẳng định việc giữ cho hệ thống ERP cốt lõi của mình "trong sạch" sẽ làm cho việc nâng cấp dễ dàng hơn, trong khi việc tùy chỉnh các hệ thống cũ, bao gồm ECC, đã làm tăng độ phức tạp và làm cho việc nâng cấp khó khăn hơn.


Michael Ameling, giám đốc sản phẩm chính của SAP, cho biết mã SAP đã giới thiệu tính năng mã hỗ trợ trí tuệ nhân tạo (AI) trong ngôn ngữ ABAP riêng của họ. Tính năng này được áp dụng trong môi trường phát triển ứng dụng dựa trên đám mây của SAP. Tuy nhiên, các nhà phát triển lo ngại rằng công nghệ tương tự không sẽ có sẵn cho các hệ thống on-prem mà họ đang làm việc để chuyển đổi lên đám mây. Các tính năng mã hỗ trợ AI của SAP bao gồm SAP Build Code và ABAP Cloud Environment. Cả hai tính năng này đang trong giai đoạn xem trước và dự kiến ​​sẽ ra mắt vào năm tới. SAP cũng nhấn mạnh việc giữ cho hệ thống ERP cốt lõi của họ "trong sạch" sẽ làm cho việc nâng cấp dễ dàng hơn, trong khi việc tùy chỉnh các hệ thống cũ gây khó khăn cho quá trình nâng cấp.

Wednesday, January 10, 2018

Operators in OOP

Operators in OOP

1. ME Operator in Methods

When you declare a variable of any type in public section of a class, you can use it in any other implementation. A variable can be declared with an initial value in public section. We may declare the variable again inside a method with a different value. When we write the variable inside the method, the system will print the changed value. To reflect the previous value of the variable, we have to use ‘ME’ operator.
In this program, we have declared a public variable text1 and initiated with a value. We have declared the same variable again, but instantiated with different value. Inside the method, we are writing that variable with ‘ME’ operator to get the previously initiated value. We get the changed value by declaring directly.

Example

Report ZMEOperator1.
CLASS class1 Definition.
  PUBLIC Section.

    Data text1 Type char25 Value 'This is CLASS Attribute'.
    Methods method1.
ENDCLASS.

CLASS class1 Implementation.
  Method method1.

    Data text1 Type char25 Value 'This is METHOD Attribute'.
    Write: / MEtext1,
           / text1.
  ENDMethod.
ENDCLASS.

Start-Of-Selection.
  Data objectx Type Ref To class1.
  Create Object objectx.
  CALL Method objectxmethod1.
The above code produces the following output −
This is CLASS Attribute
This is METHOD Attribute

2. Casting operator

?= is used to type cast an object reference of an inherited class to an object of the super class from which it is derived.
<object reference of parent class> ?= <object reference of inherited class>

Type casting helps you to refer several object references of sub classes whose type is resolved only at run time. The parent class object reference can hold the objects and often there would be a method of parent class which can be used to determine what sub class object the type cast reference is holding at run time.

Static Type and Dynamic Type
Each reference variable has a dynamic type and a static type.
  • The dynamic type is defined at run-time of the program (the type is defined when program is running), and is the data type of the data object or the class of the object to which the reference variable points. It determines the components contained in the object. The dynamic type of an initial data reference variable is the predefined generic type data. The dynamic type of an initial object reference variable is the predefined generic type object.
  • The static type is set with the declaration of the reference variable. In data references, the static type is either a non-generic data type or the predefined generic type data. In object references, the static type is either a class or an interface, so an object reference can also be referred to as a class reference or an interface reference.
The static type of a reference variable is always less specific or the same as the dynamic type.

Up Cast and Down Cast
In an assignment between reference variables, the target variable adopts the dynamic type of the source variable. An assignment is possible if the static type of the target variable is less specific or the same as the dynamic type of the source variable.

Up Cast
If the static type of the target variable is less specific or the same as the static type of the source variable, assignment is always possible. The name up cast arises from the fact that you are moving upwards within the inheritance space. As the target variable can accept more dynamic types in comparison to the source variable, this assignment is also know as a widening cast. An up cast is possible in all ABAP statements in which the content of a data object is assigned to another data object. This includes, for example, assignments with the normal assignment operator (=), the insertion of rows in internal tables, or passes from actual to formal parameters.

Down Cast

If the static type of the target variable is more specific than the static type of the source variable, you must check at runtime before the assignment is executed, whether it is less specific or the same as the dynamic type of the source variable. The name down cast arises from the fact that you are moving downwards in the inheritance space. Because the target variable can accept fewer dynamic types in comparison to the source variable, this assignment is also known as a narrowing cast. A down cast is only possible using the special assignment operator ?= (casting operator) or the statement MOVE ... ?TO .... If this prerequisite is not met, a handleable exception is raised and the reference variable keeps its original value.

Thursday, November 16, 2017

Output Determination (Transaction NACE)

Output Determination
Output determination is a term which is used to get the print, fax or e-mail outputs for different documents (PO, SO, Delivery, ..) in SAP. Output is carried out based on the conditions that you define in Customizing. You can define conditions for each output type and processing medium.

Configuration is same as Pricing in SAP, where you have Condition tables, Output Types, Access Sequence & Output determination procedures. This combination is commonly known as "Condition Technique in SAP".

How to Generate an Output
For example, to print the Sale Order

Go to VA02 or VA03
Enter your document number
Select the menu option

You can print the Output from here

Or

In the same manner, you can generate the output from here


Message Types
In this example, you define the message types for purchasing documents.

The message type denotes different kinds of message in the SAP System (for example, communications sent to vendors, such as purchase orders, order acknowledgments, reminders, expediters etc.).

To define a message type, you must enter the following:
  • Message type (Output type)
Alphanumeric key of up to 4 characters, uniquely identifying a message type.
  • Access sequence
Key for the access sequence.
  • Detail data (only the most important data is described):
◦ Transmission medium
One-character numeric key determining the type of message processing (e.g. printout, transmission as fax or e-mail).
◦ Time-spot
One-character numeric key defining the point in time at which message processing takes place (e.g. immediately a document is saved or with the next selection run).
◦ Partner role
Partner role defining the recipient.
◦ Condition access
Indicator allowing you to specify that the default value for the relevant message is to be determined using the condition technique.
◦ Access TNADR
One-character, numeric key defining the conditions upon which the print parameters are determined (see the section "Adjust Forms")


Customizing Setting
Enter Tcode NACE
Select the application
Maintain condition table (or create new one)

Create a new output type

Select your “access sequence” for the output type

Double-click on Processing routines, you can define the driver program, routine and its form

Now you have to assign the newly created output determination procedure to your order types
In case you allocate based on the criterias from document header (e.g. Order type)
Enter output procedure & output type which correspond to order type

How to Create Master Data for your Output Type

Now It’s time to maintain Master Data for Ouput Type
Enter the Output Type

System will prompt you with the “Access Sequence” as you specified in the configuration


Now to select the “Output Device”, click on the condition record and press “Communication”
Do the neccessary settings and save your output condition record

Enter an Inquiry Order and generate Output for that

This output will automatically appears here after you enter that master data in VV01. Otherwise you have to enter it manually.

Simple Formatting & Output

This post covers the topic of simple output (write a line of text to the screen) with some formatting.


  • Write: 
    • The WRITE statement outputs the contents of a text, a field or constant in a format appropriate to the data type.  ABAP data types will be discussed in detail during the next topic, ABAP Data.
    • Successive WRITE statements output data,  separated by one space,  on the same output line. When an output line is full,  output continues on the next line.
    • The SKIP statement generates blank lines.

  • Text Symbols
    • Texts are centrally managed by using the TEXT ELEMENTS function either from the editor’s initial screen, from within the editor Edit -> Text elements, or from the program code (Goto -> Text elements), or by double-clicking on the ‘text’(003) word.
    • Text symbol can be addressed by text-### or 'textliteral'(###). If the text symbol ### exists in the text pool for the logon language, this is the same as using text-###. Otherwise, the literal 'textliteral' is used as the content of the text symbol. 
    • The primary advantage of Text symbols is that they can be managed separately for different languages (Goto -> Translation).
  • Offsets and Length
    • +off(len)
      • off: the start column position for the output value.
      • len: the output length for the output value
    • Most of the time in ABAP, we may have to read the part of data of a field (say X) and populate to other field (Say Y). In this case we have to use the offset concept to read the value.
    • Example:
      SY-DATUM is the standard SAP field, which holds the current system date. The format of the date in SY-DATUM field will be YYYYMMDD.

      Where,
      • YYYY => Year
      • MM => Month
      • DD => Day
      In most of the cases we may have to read the value of month form the SY-SATUM and pass to some variable. Similarly we may have to read the value of year & day.
*--Use offset concept & populate the Year, Month & Day value to Local valriable
*--Year: Starting form Zeroth Position next 4 characters

l_year sy-datum+0(4).
*--Month: Starting form fourth Position next 2 characters
l_month sy-datum+4(2).
*--Day: Starting form sixth Position next 2 characters
l_day sy-datum+6(2).
  •  Titles and Colums
    • Title and column headings can be maintained either with the Text elements function from the initial editor screen, from within the editor (Edit -> Text elements, Titles and Headers), or from the program code (Goto -> Text elements, Titles and Headers).
    • An alternative possibility is to maintain column headings when the list is printed - System --> List --> List Header or shortcut ‘%CH’.
    • The list header appears as the first header line in the list.  If no list header is maintained,  the report title (program name from attributes screen) is used instead.
    • Positioning of the text is judged by the ruler marks above each line.
    • Texts can be maintained in the various system languages (Goto -> Translation menu option from within the Titles and Headers maintenance screen).
    • Don’t forget to save !




Saturday, April 22, 2017

Insert/Update data into Database Table

Start of Content Area

1. Inserting Lines into Tables 

The Open SQL statement for inserting data into a database table is:
INSERT INTO target lines.
It allows you to insert one or more lines into the database table target. You may specify the database table target either statically or dynamically.

Specifying a Database Table

To specify the database table statically, enter the following for target:
INSERT INTO dbtab [CLIENT SPECIFIED] lines.
where dbtab is the name of a database table defined in the ABAP Dictionary.
To specify the database table dynamically, enter the following for target:
INSERT INTO (name) [CLIENT SPECIFIED] lines.
where the field name contains the name of a database table defined in the ABAP Dictionary.
You can use the CLIENT SPECIFIED addition to disable automatic client handling.

Inserting a Single Line

To insert a single line into a database table, use the following:
INSERT INTO target VALUES wa.
You can also insert single lines using the following shortened form of the INSERT statement:
INSERT target FROM wa.
Using FROM instead of VALUE allows you to omit the INTO clause.

Inserting Several Lines

To insert several lines into a database table, use the following:
INSERT target FROM TABLE itab [ACCEPTING DUPLICATE KEYS].
This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.

Examples

Example
Adding single lines
TABLES spfli.
DATA wa TYPE spfli.
wa-carrid = 'LH'.
wa-cityfrom = 'WASHINGTON'.
...
INSERT INTO spfli VALUES wa.
wa-carrid = 'UA'.
wa-cityfrom = 'LONDON'.
...
INSERT spfli FROM wa.
spfli-carrid = 'LH'.
spfli-cityfrom = 'BERLIN'.
...
INSERT spfli.
This program inserts a single line into the database table SPFLI using each of the three possible variants of the INSERTstatement.
Instead of
INSERT spfli.
in the last line, you could also use the longer forms
INSERT spfli FROM spfli
or
INSERT INTO spfli VALUES spfli
here. The name SPFLI is therefore not unique.
These variations of the INSERT addition only work with table work areas that have been declared using TABLESand should therefore no longer be used.
Example
DATA: itab TYPE HASHED TABLE OF spfli
                WITH UNIQUE KEY carrid connid,
      wa LIKE LINE OF itab.
wa-carrid = 'UA'. wa-connid = '0011'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
wa-carrid = 'LH'. wa-connid = '1245'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
wa-carrid = 'AA'. wa-connid = '4574'. wa-cityfrom = ...
INSERT wa INTO TABLE itab.
...
INSERT spfli FROM TABLE itab ACCEPTING DUPLICATE KEYS.
IF sy-subrc = 0.
  ...
ELSEIF sy-subrc = 4.
  ...
ENDIF.
This example fills a hashed table itab and inserts its contents into the database table SPFLI. The program examines the contents of sy-subrc to see if the operation was successful.


2. Updating Lines into Tables 

Change a specific field in an SAP database table 
Changing a values within a database table using the UPDATE command is very useful function to perform. Although if you want to update a number of fields in the table you may want to use the MODIFY command.


data: ld_ebeln type ekko-ebeln.

update EKKO set ERNAM = sy-uname
 where ebeln = ld_ebeln.

Before/After inserting/updating database table, you must lock/unlock database table using lock object (se11) or FM ENQUEUE_E_TABLE/DEQUEUE_E_TABLE


End of Content Area

SAP giới thiệu mã hỗ trợ AI trong ngôn ngữ ABAP riêng của mình

SAP đã ra mắt một loạt tính năng mã hỗ trợ AI trong môi trường phát triển ứng dụng dựa trên đám mây của mình, đồng thời tham gia vào danh sá...