Limit on the length of the email subject line Let’s move forward. Make sure the subject line of your email is longer than fifty characters. In certain situations, the email’s title may be longer than 50 characters, depending on the business requirement. Email subjects are limited to 50 characters by the capability module SO_NEW_DOCUMENT_ATT_SEND_API1, which is commonly used when sending mails from SAP.
Therefore, we really want to look for a way to deliver communications in these situations. To complete this, we can use the Business Correspondence Administration (CL_BCS) class. Make sure the subject line of your email is longer than fifty characters.
CL_BCS is a class that fills in as the connection point from BCS to the applications. The strategies for the class cater for the sending capabilities.
TYPES: BEGIN OF t_mail_body. INCLUDE TYPE solisti1. TYPES: END OF t_mail_body.
CONSTANTS: c_check TYPE char1 VALUE ‘X’, c_mode TYPE char3 VALUE ‘INT’, c_doc_type TYPE char3 VALUE ‘RAW’.
DATA : i_mail_body TYPE STANDARD TABLE OF t_mail_body, k_doc_data TYPE sodocchgi1, v_subject TYPE char255. DATA: lv_cnt TYPE i, lv_sub TYPE string, lv_receiver TYPE ad_smtpadr, l_ref_send_request TYPE REF TO cl_bcs, l_ref_document TYPE REF TO cl_document_bcs, l_ref_sender TYPE REF TO cl_sapuser_bcs, l_ref_recipient TYPE REF TO if_recipient_bcs, l_ref_bcs_exception TYPE REF TO cx_bcs, lv_sent_to_all TYPE os_boolean.
CLEAR: k_doc_data.
* Populate the email body in internal table i_mail_body[].
* Fill the document data. DESCRIBE TABLE i_mail_body LINES lv_cnt.
* ——— set sender ——————————————- * note: this is necessary only if you want to set the sender * different from actual user (SY-UNAME). Otherwise sender is * set automatically with actual user.
*Executing the standard mail sending program for immediate dispatch of mail SUBMIT rsconn01 WITH mode = c_mode AND RETURN. ” Mode is INT’
If it’s not too much trouble, note: You can not see the email subject in SAP Exchange code SOST. In any case, in the real email inbox you will actually want to see the headline.
Benefits:
1) This has practically every one of the elements present in the normal FM SO_NEW_DOCUMENT_ATT_SEND_API1.
2) what’s more we can send email with the message lines more noteworthy than 50 characters.
Before showing How to SPLIT Data in FOR LOOP Using Modern ABAP Syntax? SAP ABAP Designers are know all about Circle — ENDLOOP sentence structure. FOR Circle is moderately new to ABAPers; however, other programming language use it generally. Each engineer has seen this linguistic structure in some or other programming language: for (i=1; i<=3; i++). How could ABAP remain behind?
Whatever the case, previous habits are still present. It is difficult for the slow engineers who were accustomed to standard ABAP programming to use the new punctuation. Today’s article will look at one need that we can definitely meet with the old ABAP, but the new punctuation calls for some help.
The question we asked in our SAP Specialized Wire Gathering and How to SPLIT Data in FOR LOOP Using Modern ABAP Syntax is the result of this post once more. Wesley Massini, one of our real, vibrant, and helpful people, had a program in which he was reading data from a document of a set length. It went perfectly and without any problems. In any case, the document information is no longer fixed once the company decided to separate the content using the highlight “_” later on. At the delimiter highlight, they must separate the data into portions. This delimiter can be anything, such as a pipe (|), tilds (~), or comma (,).
Sounds a simple necessity right? Be that as it may, could you at any point do utilizing the new ABAP Sentence structure?
Existing Code for Fixed Length Data
The data in the file would look like this:
It is a document with heterogeneous information. The information in the primary column and second line are unique. For instance, the initial two fields (yellow and blue) in both the columns are Plant and Material. Yet, the third field in red is Seller is first column and keeping in mind that it is a marker in second line. Comparatively fourth field in green is a custom sort in first column and some classification in second line. The thought is, every one of the information columns in the document for type initially ought to go to one inner table and all lines like that of second sort ought to go into another interior table.
We involved SWITCH articulation in new language structure and isolated the columns in view of the length of the information in the document (which is fixed). Column type one has 26 characters while line type two has 18 characters. Likewise, we don’t have to show the augmentation .txt.
As creator and ABAPer Paul Solid says, Compact discs is ABAP in Steriods. We say, not just Compact discs, the new ABAP itself seems to be really dynamic ABAP.
Check the above screen capture. We have In-line information statement, utilization of Significant worth, FOR Circle in inside table, SWITCH and #. Do a F4 on every one of these catchphrases and attempt to figure out the idea.
For our case, we have know the Sort, consequently they come after the Worth administrator. Additionally after SWITCH there is #. The table sorts are announced like underneath.
In order to display the output, we can write the below syntax.
Output
How to Handle Blank Rows?
We are don’t know, how to keep away from the clear lines in both the tables utilizing the cutting edge punctuation. We utilized an Erase proclamation expressly after the information was populated in the inward tables.
Assuming you know how to eliminate the clear lines in the FOR Circle with SWITCH, kindly give the arrangement in the remarks segment. We will refresh this article with your answer.
* Delete Blank Lines
DELETE it_vm_data_tab WHERE werks IS INITIAL.
DELETE it_pm_data_tab WHERE werks IS INITIAL.
New Requirement
Prior our document was fixed length. With the business change, we began getting document with a delimiter highlight ““. In this way, we didn’t have to stress over the length of each fields. Once more, be that as it may, we battled to sort out the most ideal way to Part at “” utilizing new ABAP.
Solution 1
After some examination and with our new information, we accomplished the usefulness utilizing STRLEN, SUBSTRING_BEFORE, SUBSTRING_AFTER , sub, occ string capabilities alongside the Worth and FOR Circle and COND watchwords.
Note: The catchphrase occ is for Event. You could see a negative number for occ = – 1. In the event that occ is positive worth, the events are counted from the left while in the event that occ is a negative number, it is counted from the right side.
Correspondingly check the watchword sub. It is for Substring. Sub searches for the characters in the string.
DATA result TYPE string.
result = substring( val = 'ABCDEFGH' off = 2 len = 2 ).
result = substring_from( val = 'ABCDEFGH' sub = 'CD' ).
result = substring_after( val = 'ABCDEFGH' sub = 'CD' ).
result = substring_before( val = 'ABCDEFGH' sub = 'CD' ).
result = substring_to( val = 'ABCDEFGH' sub = 'CD' ).
The above bit is from SAP Help to show the utilization of SUB and different SUBSTRING capabilities. The result for each outcome is “Disc”, “CDEFGH”, “EFGH”, “Stomach muscle”, and “ABCD” in a similar request.
The above code likewise gave a clear line and we had to unequivocally utilize the Erase explanation. Likewise, we had COND in the grammar which could be stayed away from. We accomplished the business necessity, yet we were all the while contemplating whether there is a superior method for accomplishing it. Without the Erase articulation and COND. Also, prepare to be blown away. Stephan gave a faultless arrangement once more!!
Solution 2 from Stephan
Stephan prescribed to place an identifier in the start of the information line for the document. For our case, it is VM and PM. Additionally, with his new arrangement rationale there is compelling reason need to utilize COND.
Actually take a look at the arrangement above. He has utilized WHERE condition in the FOR Circle. There is no requirement for WHEN and afterward. Additionally, the STRLEN check of each column is forestalled alongside COND #.
Code Snippet
* Types Declaration
TYPES:
BEGIN OF ty_vm_file,
werks TYPE werks_d,
matnr TYPE matnr,
lifnr TYPE lifnr,
ztype TYPE char1,
END OF ty_vm_file,
BEGIN OF ty_pm_file,
werks TYPE werks_d,
matnr TYPE matnr,
htype TYPE char1,
zcagn TYPE char2,
END OF ty_pm_file,
BEGIN OF ty_filename,
filename TYPE text1024,
END OF ty_filename,
* Table Type declaration
tt_vm_tab TYPE TABLE OF ty_vm_file WITH EMPTY KEY,
tt_pm_tab TYPE TABLE OF ty_pm_file WITH EMPTY KEY,
tt_filename_tab TYPE TABLE OF ty_filename WITH EMPTY KEY.
* My recommendation is to put an identifier at the beginning of the filename like in this sample.
* With this logic there is no need for usage of COND like in the first sample.
DATA(it_fillename_data_tab) = VALUE tt_filename_tab( ( filename = 'VM_CA02_0074203_0000102207_H.txt' )
( filename = 'PM_CA02_0074203_C_HA.txt' ) ).
DATA(it_vm_data_tab) = VALUE tt_vm_tab( FOR ls_filename IN it_fillename_data_tab
WHERE ( filename(3) EQ 'VM_' )
( werks = substring_after( val = substring_before( val = ls_filename-filename sub = '_' occ = 2 ) sub = '_' occ = 1 )
matnr = substring_after( val = substring_before( val = ls_filename-filename sub = '_' occ = 3 ) sub = '_' occ = 2 )
lifnr = substring_after( val = substring_before( val = ls_filename-filename sub = '_' occ = 4 ) sub = '_' occ = 3 )
ztype = substring_after( val = substring_before( val = ls_filename-filename sub = '.' occ = -1 ) sub = '_' occ = -1 )
) ).
DATA(it_pm_data_tab) = VALUE tt_pm_tab( FOR ls_filename IN it_fillename_data_tab
WHERE ( filename(3) EQ 'PM_' )
( werks = substring_after( val = substring_before( val = ls_filename-filename sub = '_' occ = 2 ) sub = '_' occ = 1 )
matnr = substring_after( val = substring_before( val = ls_filename-filename sub = '_' occ = 3 ) sub = '_' occ = 2 )
htype = substring_after( val = substring_before( val = ls_filename-filename sub = '_' occ = 4 ) sub = '_' occ = 3 )
zcagn = substring_after( val = substring_before( val = ls_filename-filename sub = '.' occ = -1 ) sub = '_' occ = -1 )
) ).
* Add both table data for display
cl_demo_output=>write_data( it_vm_data_tab ).
cl_demo_output=>write_data( it_pm_data_tab ).
** Show the output
cl_demo_output=>display( ).
SAP Google Maps integration We are going to Calculator in SAP using New ABAP Syntax. SAP HANA is Hot. Fiori/UI5 is Cool. OData is Captivating. Yet, in every one of these tomfoolery, fundamental ABAP is as yet flourishing. This article is an illustration of the fundamental ABCs of ABAP which we really want till ABAP doesn’t get wiped out (which won’t ever occur) later on SAP World. Darwin’s law of Advancement holds great to ABAPers also. ABAPers need to advance and get new deceives of the game in their kitty, to remain ahead in the opposition. In this article, I have attempted to show case a portion of the New Language structures of ABAP, which makes programming more straightforward and diminishes the code impressions. Calculator in SAP using New ABAP Syntax.
Calculator in SAP using New ABAP Syntax.
The setting behind this article: Calculator in SAP using New ABAP Syntax!
Question: The outcome ought to be imprinted in Outcome box rather than the Info text. For instance, for Information ‘2+3’ I want the Outcome ‘5’ to be imprinted in outcome box. What I have done is, doled out the Info field ‘IN’ to Result field ‘RES’.
Reply from @Anask (in few seconds or less. That the excellence of this gathering): It regards the variable as string and simply duplicates content of one field to another. You want to part at SIGN and get information into 2 separate fields and afterward do the administrator activity. Simply utilize Split and afterward figure it out activity. Use CASE articulation and split in light of the sign it contains.
SPLIT lv_input AT lv_operator
INTO lv_operand1
lv_operand2.
I’m individuals from numerous WhatsApp and Wire and different gatherings. However, this SAP Specialized Gathering is the most dynamic one where we have lots of conversations consistently. Most Inquiries get Addressed or if nothing else get a few thoughts for the arrangement. In the event that you have not joined at this point, check it out. It is completely safe. Furthermore, nobody can realize your portable number, not even the Administrators. You really want to have Wire Application introduced in your gadget before you join the gathering utilizing the beneath connect.
All things considered,I’m a SAP ABAP Designer. I’m the pioneer behind Köster Counseling. If it’s not too much trouble, actually look at my site for more data.
Enough of me. Presently, lets return to the top story. On the off chance that you are a beginner of ABAP7.4, a portion of the focuses which you really want to note in the underneath SAP Mini-computer Program are:
INSERT |{ lv_result }| INTO gt_string_tab INDEX lv_tabix - 1.
5. Inline Data Declaration in Class Methods
* Call the Class Method to do the calculation
zcl_stkoes_calc=>do_calculation(
EXPORTING
iv_formula = <gv_calc>
RECEIVING
rv_result = DATA(gv_result)
EXCEPTIONS
division_by_zero = 1 " Division By Zero
missing_number_at_beginning = 2 " Missing Number at the beginning
missing_number_at_end = 3 " Missing Number at the end
two_operator_not_allowed = 4 " Two Operator are not allowed
unknown_error = 5 " Unknown Error
OTHERS = 6 ).
Did you check gv_result is announced during the call of the technique do_calculation.
Note: We Can’t do comparable Inline Information Statement while calling a Capability Module. Just accessible in Class Technique.
6. MESSAGE with SWITCH
MESSAGE |{ SWITCH #( sy-subrc
WHEN 1 THEN |Division by zero|
WHEN 2 THEN |Missing number at the beginning|
WHEN 3 THEN |Missing number at the end|
WHEN 4 THEN |Two operator is not allowed|
WHEN 5 THEN |Unknown Error|
ELSE |Other Error| ) }| TYPE 'S' DISPLAY LIKE 'E'.
Allow me to show you, what the Adding machine can do. It does the essential +, – , X,/mathematic activities. Be that as it may, the rationale and idea which I have placed in the class can be extrapolated to many genuine use case real venture prerequisites.
I have purposely utilized the Macros to cause you to comprehend how Macros can in any case be utilized. Assuming you feel, macros are not required, you can do the immediate Radio Buttons in the Choice Screen without the Macros.
Sample Input String for the Calculator and their corresponding Results
Sample Error Handling
Here is the finished Code which you can attempt. You can likewise download the program text document at the lower part of this article.
*&---------------------------------------------------------------------*
*& Report ZSTKOES_CALC
*&---------------------------------------------------------------------*
*& This is a Utilty Program which acts like a Simple Calculator.
*& OOPs Concept along with New ABAP7.4+ Syntaxes are used
*& Feel Free to refer and use it as required
*&---------------------------------------------------------------------*
REPORT zstkoes_calc.
CLASS zcl_stkoes_calc DEFINITION.
PUBLIC SECTION.
CONSTANTS:
BEGIN OF gcs_operators,
div TYPE char1 VALUE '/' ##NO_TEXT,
mod TYPE char3 VALUE 'MOD' ##NO_TEXT,
mul TYPE char1 VALUE '*' ##NO_TEXT,
sub TYPE char1 VALUE '-' ##NO_TEXT,
add TYPE char1 VALUE '+' ##NO_TEXT,
END OF gcs_operators.
CLASS-METHODS:
do_calculation
IMPORTING
VALUE(iv_formula) TYPE string
RETURNING
VALUE(rv_result) TYPE labst
EXCEPTIONS
division_by_zero
missing_number_at_beginning
missing_number_at_end
two_operator_not_allowed
unknown_error.
PRIVATE SECTION.
TYPES:
gtty_string TYPE TABLE OF string.
CLASS-METHODS:
convert_formula_to_string_tab
IMPORTING
VALUE(iv_formula) TYPE string
EXPORTING
VALUE(et_string_tab) TYPE gtty_string
EXCEPTIONS
missing_number_at_beginning
missing_number_at_end
two_operator_not_allowed,
calculate
IMPORTING
VALUE(it_string_tab) TYPE gtty_string
RETURNING
VALUE(rv_result) TYPE labst
EXCEPTIONS
division_by_zero
unknown_error.
ENDCLASS.
CLASS zcl_stkoes_calc IMPLEMENTATION.
METHOD do_calculation.
convert_formula_to_string_tab(
EXPORTING
iv_formula = iv_formula
IMPORTING
et_string_tab = DATA(lt_string_tab)
EXCEPTIONS
missing_number_at_beginning = 1
missing_number_at_end = 2
two_operator_not_allowed = 3 ).
IF sy-subrc EQ 0.
calculate(
EXPORTING
it_string_tab = lt_string_tab
RECEIVING
rv_result = rv_result
EXCEPTIONS
division_by_zero = 4
unknown_error = 5 ).
ENDIF.
IF sy-subrc NE 0.
CASE sy-subrc.
WHEN 1.
RAISE missing_number_at_beginning.
WHEN 2.
RAISE missing_number_at_end.
WHEN 3.
RAISE two_operator_not_allowed.
WHEN 4.
RAISE division_by_zero.
WHEN 5.
RAISE unknown_error.
ENDCASE.
ENDIF.
ENDMETHOD.
METHOD convert_formula_to_string_tab.
FIELD-SYMBOLS:
<lv_value> TYPE string.
CONDENSE iv_formula NO-GAPS.
DATA(lv_off) = 0.
DO.
IF iv_formula+lv_off(1) CN '1234567890'.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE gcs_operators TO FIELD-SYMBOL(<lv_operator>).
IF sy-subrc NE 0.
EXIT.
ENDIF.
DATA(lv_length) = strlen( <lv_operator> ).
IF iv_formula+lv_off(lv_length) EQ <lv_operator>.
IF lv_off EQ 0.
RAISE missing_number_at_beginning.
ELSEIF <lv_value> IS NOT ASSIGNED.
RAISE two_operator_not_allowed.
ENDIF.
UNASSIGN <lv_value>.
APPEND iv_formula+lv_off(lv_length) TO et_string_tab.
ADD lv_length TO lv_off.
EXIT.
ENDIF.
ENDDO.
ELSE.
IF <lv_value> IS NOT ASSIGNED.
APPEND INITIAL LINE TO et_string_tab ASSIGNING <lv_value>.
<lv_value> = iv_formula+lv_off(1).
ELSE.
<lv_value> = |{ <lv_value> }{ iv_formula+lv_off(1) }|.
ENDIF.
ADD 1 TO lv_off.
ENDIF.
IF lv_off EQ strlen( iv_formula ).
EXIT.
ENDIF.
ENDDO.
IF <lv_value> IS NOT ASSIGNED.
RAISE missing_number_at_end.
ENDIF.
ENDMETHOD.
METHOD calculate.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE gcs_operators TO FIELD-SYMBOL(<lv_operator>).
IF sy-subrc NE 0.
EXIT.
ENDIF.
DO.
ASSIGN it_string_tab[ table_line = <lv_operator> ] TO FIELD-SYMBOL(<lv_op>).
IF sy-subrc NE 0.
EXIT.
ENDIF.
DATA(lv_from) = sy-tabix - 1.
DATA(lv_to) = sy-tabix + 1.
READ TABLE it_string_tab ASSIGNING FIELD-SYMBOL(<lv_first>) INDEX lv_from.
READ TABLE it_string_tab ASSIGNING FIELD-SYMBOL(<lv_second>) INDEX lv_to.
IF <lv_first> IS ASSIGNED AND <lv_second> IS ASSIGNED.
TRY.
CASE <lv_operator>.
WHEN '/'.
DATA(lv_result) = CONV labst( <lv_first> / <lv_second> ).
WHEN 'MOD'.
lv_result = <lv_first> MOD <lv_second>.
WHEN '*'.
lv_result = <lv_first> * <lv_second>.
WHEN '-'.
lv_result = <lv_first> - <lv_second>.
WHEN '+'.
lv_result = <lv_first> + <lv_second>.
ENDCASE.
CATCH cx_sy_zerodivide INTO DATA(lo_error).
RAISE division_by_zero.
ENDTRY.
DELETE it_string_tab FROM lv_from TO lv_to.
INSERT |{ lv_result }| INTO it_string_tab INDEX lv_from.
ENDIF.
ENDDO.
ENDDO.
IF lines( it_string_tab ) EQ 1.
rv_result = it_string_tab[ 1 ].
ELSE.
RAISE unknown_error.
ENDIF.
ENDMETHOD.
ENDCLASS.
**--------------------------------------------------------------------*
** Start of Program
**--------------------------------------------------------------------*
* Macro to set one radiobutton as default (can be used only once)
DEFINE calc_default.
SELECTION-SCREEN:
BEGIN OF LINE.
PARAMETERS:
rb_calc&1 RADIOBUTTON GROUP cal DEFAULT 'X' USER-COMMAND calc&1.
SELECTION-SCREEN:
COMMENT 3(14) co_calc&1.
PARAMETERS:
pa_calc&1 TYPE string DEFAULT &2.
SELECTION-SCREEN:
END OF LINE.
END-OF-DEFINITION.
* Macro to create radiobutton without deafult
DEFINE calc.
SELECTION-SCREEN:
BEGIN OF LINE.
PARAMETERS:
rb_calc&1 RADIOBUTTON GROUP cal.
SELECTION-SCREEN:
COMMENT 3(14) co_calc&1.
PARAMETERS:
pa_calc&1 TYPE string DEFAULT &2.
SELECTION-SCREEN:
END OF LINE.
END-OF-DEFINITION.
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE gt_b01.
* Creating all paramater on SELECTION SCREEN using macro
calc_default 1 '10 + 300 / 100 * 10 - 50'.
calc 2 '+10 + 300 / 100 * 10 - 50'.
calc 3 '10 + 300 / 100 * 10 - 50+'.
calc 4 '10 + 300 / 100 * * 10 - 50'.
calc 5 '10 + 300 / 0 * 10 - 50'.
SELECTION-SCREEN END OF BLOCK b01.
INITIALIZATION.
* Filling all comments and title
co_calc1 = '1. Calculation'.
co_calc2 = '2. Calculation'.
co_calc3 = '3. Calculation'.
co_calc4 = '4. Calculation'.
co_calc5 = '5. Calculation'.
gt_b01 = 'Calculations'.
AT SELECTION-SCREEN OUTPUT.
DATA:
gv_editable TYPE rsscr_name.
* Check which radiobutton is selected
PERFORM get_field_selected_radiobutton CHANGING gv_editable.
* Leave only selected line editable
LOOP AT SCREEN.
IF screen-name(7) EQ 'PA_CALC' AND screen-name NE gv_editable.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
DATA:
gv_editable TYPE rsscr_name.
* Check which radiobutton is selected
PERFORM get_field_selected_radiobutton CHANGING gv_editable.
* Get the Formular of selected radiobutton
ASSIGN (gv_editable) TO FIELD-SYMBOL(<gv_calc>).
IF <gv_calc> IS ASSIGNED.
* Do the calculation
zcl_stkoes_calc=>do_calculation(
EXPORTING
iv_formula = <gv_calc>
RECEIVING
rv_result = DATA(gv_result)
EXCEPTIONS
division_by_zero = 1 " Division By Zero
missing_number_at_beginning = 2 " Missing Number at the beginning
missing_number_at_end = 3 " Missing Number at the end
two_operator_not_allowed = 4 " Two Operator are not allowed
unknown_error = 5 " Unknown Error
OTHERS = 6 ).
* Handle Errors
IF sy-subrc NE 0.
MESSAGE |{ SWITCH #( sy-subrc
WHEN 1 THEN |Division by zero|
WHEN 2 THEN |Missing number at the beginning|
WHEN 3 THEN |Missing number at the end|
WHEN 4 THEN |Two operator is not allowed|
WHEN 5 THEN |Unknown Error|
ELSE |Other Error| ) }| TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
ENDIF.
END-OF-SELECTION.
WRITE: gv_result.
*&---------------------------------------------------------------------*
*& Form GET_FIELD_SELECTED_RADIOBUTTON
*&---------------------------------------------------------------------*
* <--CV_EDITABLE PARAMETER of selected radiobutton
*----------------------------------------------------------------------*
FORM get_field_selected_radiobutton CHANGING cv_editable TYPE rsscr_name.
DO.
DATA(lv_fieldname) = |RB_CALC{ CONV numc1( sy-index ) }|.
ASSIGN (lv_fieldname) TO FIELD-SYMBOL(<lv_fieldvalue>).
IF sy-subrc NE 0.
EXIT.
ELSEIF <lv_fieldvalue> EQ abap_true.
cv_editable = |PA_CALC{ CONV numc1( sy-index ) }|.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
Download above program in text record.
To involve Macros for the Radio Buttons, you can download one more adaptation of a similar program with less difficult Choice screen.
Output of Version 2 of the SAP ABAP Calculator looks like below.
I trust, this article would rouse you to involve the New ABAP Linguistic structure in the entirety of your current and future turns of events. We really want to embrace the change and acknowledge it in our everyday undertakings. Change is Progress.
A brief break from HANA would be included in this essay. We would take a break and see what Open SQL has to offer. Why does it have the name Open? You’re right! “Open” means “Open to any information base,” such as an independent information base. To take advantage of the Open SQL articulations that can further enhance the way we design our apps, you do not need to have a HANA database. Open SQL ABAP 740 in the New Age.
Assuming you have been following the past posts on SAP ABAP on HANA, you would realize that Compact discs View is one more procedure to accomplish Code to Information worldview. In the event that a similar usefulness can be accomplished by the two Discs Strategy and Open SQL, which one would it be a good idea for us to take on? Now start our tutorial on New Age Open SQL ABAP 740.
Reply: SAP believes that us should remain Open. Open SQL is the best option. Then comes Discs View and afterward the put away methods (ADBC, ADMP which we will cover in our ensuing articles).
The goal of the state-of-the-art ABAP/SQL/SAP HANA is to push logic down to the database. To apply and implement the reasoning in the data set, we appropriate these significant advancements. However, keep in mind that SAP must also be approximately as open as possible. Therefore, when choosing between an information base free arrangement and a data set explicit arrangement, the last option (data set autonomous) is always chosen.
Let’s go on to the most important story. ABAP’s New Age SQL.
Preceding delivery 740, assuming we had the necessity to add an extra section in the result which didn’t exist in that frame of mind with some custom rationale, then we typically composed something like beneath.
We characterized the Sorts. We circled through the table and added the custom rationale (High Buy or Low Buy) as displayed beneath.
TYPES: BEGIN OF ty_ekpo,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
werks TYPE ewerk,
netpr TYPE bprei,
pur_type TYPE char14,
END OF ty_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF ty_ekpo.
FIELD-SYMBOLS <fs_ekpo> TYPE ty_ekpo.
SELECT ebeln ebelp werks netpr
FROM ekpo
INTO TABLE it_ekpo.
LOOP AT it_ekpo ASSIGNING <fs_ekpo>.
IF <fs_ekpo>-netpr GT 299.
<fs_ekpo>-pur_type = 'High Purchase'.
ELSE.
<fs_ekpo>-pur_type = 'Low Purchase'.
ENDIF.
ENDLOOP.
IF it_ekpo IS NOT INITIAL.
cl_demo_output=>display_data(
EXPORTING
value = it_ekpo
name = 'Old AGE SQL : 1' ).
ENDIF.
Allow us to perceive how we can accomplish exactly the same thing in another manner. With ABAP 740 or more, we dispose of TYPES, Information Announcement and Circle. Isn’t it cool?
Sample 1 ( Using comma separated fields with inline data declaration and usage of CASE for reference fields)
SELECT ebeln, ebelp, werks, netpr,
CASE
WHEN netpr > 299
THEN 'High Purchase'
ELSE 'Low Purchase'
END AS pur_type
FROM ekpo
INTO TABLE @DATA(lt_sales_order_header).
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_sales_order_header
name = 'New AGE SQL : 1' ).
ENDIF.
Yields from both the above methods are same. However, the way does matters. Isn’t it?
Assuming you have some disarray in regards to HANA.
Then, let us really look at the strong inbuilt capabilities in SELECT.
Sample 2 ( Using JOIN and COUNT / DISTINCT functions in SELECT )
PARAMETERS: p_matnr TYPE matnr,
p_lgort TYPE lgort_d.
SELECT mara~matnr,
mard~lgort,
COUNT( DISTINCT ( mard~matnr ) ) AS distinct_mat, " Unique Number of Material
COUNT( DISTINCT ( mard~werks ) ) AS distinct_plant, " Unique Number of Plant
SUM( mard~labst ) AS sum_unrest,
AVG( mard~insme ) AS avg_qlt_insp,
SUM( mard~vmspe ) AS sum_blocked
FROM mara AS mara INNER JOIN mard AS mard
ON mara~matnr EQ mard~matnr
INTO TABLE @DATA(lt_storage_loc_mat)
UP TO 1000 ROWS
WHERE mard~matnr = @p_matnr
AND mard~lgort = @p_lgort
GROUP BY mara~matnr,
mard~lgort.
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_storage_loc_mat
name = 'New AGE SQL : 2' ).
ENDIF.
Particular Material is 1 and Unmistakable Plant is 2. Total for the Unlimited stock is 2, AVG is 2/2 = 1 and Amount of Impeded stock is 2. This is only an example to exhibit how flexible and strong the SELECT proclamation has become.
Then, in our menu, today is the Numerical Administrators in SELECT. Check the underneath scrap where we can straightforwardly appoint ’10’ (as refund percent) which would be in the interior table. CEIL capability, increase, deduction and so forth can be taken care of during the SELECT assertion. In the event that we were not in 740, we would have required a different circle and pack of code to accomplish this capability. Isn’t ABAP genuine current at this point?
Sample 3 ( Using vivid mathematical operators in SELECT )
DATA: lv_rebate TYPE p DECIMALS 2 VALUE '0.10'.
SELECT ebeln,
10 AS rebate_per,
CEIL( netpr ) AS whole_ord_net,
( @lv_rebate * netpr ) AS rebate,
( netpr - ( @lv_rebate * netpr ) ) AS act_net
FROM ekpo
USING CLIENT '130'
UP TO 10 ROWS
INTO TABLE @DATA(lt_po_data).
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_po_data
name = 'New AGE SQL : 3' ).
ENDIF.
Math is fun with ABAP 740, yet additionally legitimate programming. Go on underneath to taste the new flavor.
Sample 4 ( Using Complex Case statement on non-referenced fields i.e. multiple in one Select )
PARAMETERS: p_werks TYPE werks_d.
DATA:
lv_rebate TYPE p DECIMALS 2 VALUE '0.10',
lv_high_rebate TYPE p DECIMALS 2 VALUE '0.30'.
SELECT ebeln,
werks,
CEIL( netpr ) AS whole_ord_net,
( @lv_rebate * netpr ) AS rebate,
( netpr - ( @lv_rebate * netpr ) ) AS act_net,
CASE WHEN werks = @p_werks " For specific plant
THEN @lv_rebate
ELSE @lv_high_rebate
END AS rebate_type,
CASE WHEN werks = @p_werks " For specific plant
THEN 'low rebate'
ELSE 'high rebate'
END AS low_high
FROM ekpo
USING CLIENT '130'
UP TO 25 ROWS
INTO TABLE @DATA(lt_po_data).
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_po_data
name = 'New AGE SQL : 4' ).
ENDIF.
Blend’s exacting importance from the word reference is ‘met up and shape one mass or entire’ or ‘join (components) in a mass or entirety’.
As per SAP documentation, the Mix capability in Open SQL returns the worth of the contention arg1 (in the event that this isn’t the invalid worth); in any case, it returns the worth of the contention arg2. A clear should be set after the initial enclosure and before the end bracket. A comma should be put between the contentions
Really take a look at the use underneath. In the event that information for ekko~lifnr is available (implies PO is made for the lessor) then the LIFNR (Merchant Number) from EKKO is printed else, ‘No PO’ strict is refreshed. This capability is very helpful in numerous genuine functional situations.
Sample 5 ( Using COALESCE and Logical operators like GE / GT/ LE / LT etc in JOIN which was originally not available
SELECT lfa1~lifnr,
lfa1~name1,
ekko~ebeln,
ekko~bukrs,
COALESCE( ekko~lifnr, 'No PO' ) AS vendor
FROM lfa1 AS lfa1 LEFT OUTER JOIN ekko AS ekko
ON lfa1~lifnr EQ ekko~lifnr
AND ekko~bukrs LT '0208'
INTO TABLE @DATA(lt_vend_po)
UP TO 100 ROWS.
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_vend_po
name = 'New AGE SQL : 5' ).
ENDIF.
How frequently and in what number of activities did you have the prerequisite to print Endlessly establish depiction together like 0101 (Houston Site) or in structures you had the necessity to compose Payee (Payee Name)? We accomplished it by circling and connecting. We didn’t have better choice prior, yet presently we can do it while choosing the information. On account of the SAP Improvement Group.
Sample 6 (Concatenation while selecting data )
SELECT lifnr
&& '(' && name1 && ')' AS Vendor,
ORT01 as city
FROM lfa1
INTO TABLE @DATA(lt_bp_data)
UP TO 100 ROWS.
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_bp_data
name = 'New AGE SQL : 6' ).
ENDIF.
Each report/transformation/interface requests that we approve the information and we do it by checking its presence in the actually look at table. That has become simpler and better presently like displayed underneath.
Sample 7 ( Check existence of a record )
SELECT SINGLE @abap_true
FROM mara
INTO @DATA(lv_exists)
WHERE MTART = 'IBAU'.
IF lv_exists = abap_true.
WRITE:/ 'Data Exists!! New AGE SQL : 7'.
ENDIF.
ABAP was dependably a fifth era programming language and it has become all the more so. It has become more comprehensible and genuine grammatically as well. . HAVING capability is one more quill to the crown.
Sample 8 ( Use of HAVING functions in SELECT )
SELECT lfa1~lifnr,
lfa1~name1,
ekko~ebeln,
ekko~bukrs
FROM lfa1 AS lfa1 INNER JOIN ekko AS ekko
ON lfa1~lifnr EQ ekko~lifnr
AND ekko~bukrs LT '0208'
INTO TABLE @DATA(lt_vend_po)
GROUP BY lfa1~lifnr, lfa1~name1, ekko~ebeln, ekko~bukrs
HAVING lfa1~lifnr > '0000220000'.
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_vend_po
name = 'New AGE SQL : 8' ).
ENDIF.
Keep in mind, some of the time we really want to choose all fields of more than one table and give custom names in the result. Wasn’t it tedious to make TYPEs and accomplish our prerequisite?
Test 9 ( Utilization of choice of all segments with renaming of fields. This is helpful in the event that you need to do all field select )
I thought with ABAP 740, I could do the underneath.
SELECT jcds~*,
tj02t~*
FROM jcds INNER JOIN tj02t
ON jcds~stat = tj02t~istat
WHERE tj02t~spras = @sy-langu
INTO TABLE @DATA(lt_status)
UP TO 1000 ROWS.
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_status
name = 'New AGE SQL : 9' ).
ENDIF.
The above code is linguistically right. Amazing!! I was so eager to test it as it would show all sections from both the tables.
Uh oh!! We receive the above message. Too soon to be so cheerful.
Allow us to change a similar code a tad. We want to characterize the Sorts and pronounce the interior table (Inline didn’t work above).
TYPES BEGIN OF ty_data.
INCLUDE TYPE jcds AS status_change RENAMING WITH SUFFIX _change.
INCLUDE TYPE tj02t AS status_text RENAMING WITH SUFFIX _text.
TYPES END OF ty_data.
DATA: lt_status TYPE STANDARD TABLE OF ty_data.
SELECT jcds~*,
tj02t~*
FROM jcds INNER JOIN tj02t
ON jcds~stat = tj02t~istat
WHERE tj02t~spras = @sy-langu
INTO TABLE @lt_status
UP TO 100 ROWS.
IF sy-subrc = 0.
cl_demo_output=>display_data(
EXPORTING
value = lt_status
name = 'New AGE SQL : 9' ).
ENDIF.
Check _CHANGE is added to the field name. _TEXT is additionally included the section name from second table (not caught in the screen print beneath)
These were only the tip of the chunks of ice. We would coincidentally find more elements and shocks as we work on projects in genuine framework. Just to tell you, all the above code pieces are from a customary data set (not HANA) which has EhP 7.4. So don’t confound that we really want HANA data set to exploit present day SQL strategies. We simply need close or more EhP 7.4.
We inquired as to whether Compact discs Perspectives and SQL can accomplish a similar usefulness. Which one would it be a good idea for us to pick?
Master Simon Bain (Chief SearchYourCloud Inc.) said: I guess the response would be one more inquiry or set of inquiries. In your application do you right now utilize Compact discs? Are your engineers proficient on Discs? On the off chance that yes to both, most likely Discs Perspectives. In the event that there is an expectation to learn and adapt, go for the more well known SQL and train the improvement group for the following update, as opposed to placing in code that they are either discontent with or have little information on.
Toward the day’s end, I would agree that utilization whichever one turns out best for your undertaking, group and application. The client shouldn’t see any distinction in convenience. Everything no doubt revolves around support and information by the day’s end.
To get such valuable articles straightforwardly to your inbox, if it’s not too much trouble, Buy in. We regard your security and view safeguarding it in a serious way.
Let’s begin by discussing secondary indexes in SAP HANA and traditional SAP databases. Since a list is an organized copy of the selected data set table fields, we all know that a file in a data set table helps to retrieve the selected column more quickly. In real-world scenarios and practical endeavors, we often lack the necessary keys in our decision boundaries; as a result, the complete table needs to be examined without the necessary list. We are persuaded to create Optional Records in exemplary non-HANA SAP Data Set tables in these situations. SAP HANA and traditional SAP databases both have secondary indexes.
By and large, making Auxiliary Record makes information recovery quicker. Be that as it may, we need to pay something for this Optional Record. What is the cost of having Auxiliary List? Secondary Index in Traditional SAP Database and SAP HANA Database.
Reply:
1) Each time a passage is saved in the data set table, there is an extra above of refreshing the Auxiliary Files. Each extra record dials back the addition of columns in the table.
2) On the off chance that we have an excessive number of Auxiliary Lists for the information base table, odds are there that the capacity memory consumed for these files is nearly essentially as immense as need might have arisen for the entire data set table itself.
3) Premise Group needs to invest a lot of energy routinely to redesign the records that get divided over the long haul.
4) An excessive number of files can likewise cause the information base framework enhancer to choose some unacceptable record. To forestall this, the files in a table should share as couple of fields as could be expected.
What number of Optional Lists would it be a good idea for us to have in an exemplary data set table? Reply: SAP suggests something like five auxiliary files.
When would it be a good idea for us to make Optional File?
Reply:
1) The fields in an Optional List ought to be fields through which we frequently select. The field or fields of an optional list ought to be particular to the point that each file section compares to exceptionally least percent of the complete passages in the table. SAP suggests Optional List ought to hold a limit of 5% of the all out number of table passages.
2) Auxiliary files are to be made exclusively for information base tables where the read gets to are additional time-basic than the compose gets to since each made list must be kept up with for compose gets to.
3) The fields that are probably going to be questioned with the = administrator ought to be toward the start of the list.
WHERE Proviso for Auxiliary Record:
1) ‘=’ (Equivalent to Administrator), IN conditions ‘AND’ joins are productively upheld by Auxiliary File, i.e they love Positive administrators. Auxiliary Record additionally works for LIKE proviso on the off chance that you can’t give EQ, IN statement. IN implies various EQ for a section. Consequently, IN is viable in WHERE Condition.
2) Negative situations such as <>, NE, and NOT should be avoided. We should change the WHERE clause to make it sure if at all possible. In any case, we should identify the circumstances in the WHERE condition and not completely ignore them if this is absurd. This is the primary method used to choose the relevant information records. Any other technique would violate the exhibition rule as you would be looking through useless records that you would then have to remove in the ABAP program.
3) In the event that you don’t determine all fields in the list, ensure that you encase the underlying part of the file in the WHERE condition. In any case, the utilization of a record is beyond the realm of possibilities as a rule.
The enhancer for the most part stops on the off chance that the determination condition contains an ‘OR’. As such, it doesn’t assess the fields checked by ‘OR’ while choosing and applying the record. An exemption for this is ‘OR’ connections remaining all alone. Thusly, conditions containing an OR join for one of the filed fields ought to be reformulated if vital.
The optimizer stops working when it encounters OR in the following SELECT statement.
Not Recommended
SELECT * FROM spfli
WHERE carrid = 'LH' AND
( CITYFROM = 'FRANKFURT' OR cityfrom = 'NEW YORK' ).
When replaced by the equivalent statement (below), the entire condition can be optimized with respect to the existing indexes.
Better use of ‘OR’ clause.
SELECT *
FROM spfli
WHERE ( carrid = 'LH' AND cityfrom = 'FRANKFURT' ) OR
( carrid = 'LH' AND cityfrom = 'NEW YORK' ).
What is the SAP Table which stores the file names and data for any data set table? Reply: DD12L – R/3 S_SECINDEX: auxiliary lists, header
Above we discovered that SAP suggests greatest 5 Optional Files be made. Actually, what number of Optional Files could we at any point make in conventional (non-HANA) SAP data set? There are many responses in famous SAP Discussion. Some say 9 others say 16 and some say limitless.
Reply: I checked our SAP framework and found that we have Auxiliary Lists to the count of 25. Check, even the MARA table has 16 records.
Some place in the Discussion, that’s what I read, SAP tosses a message when we attempt to make in excess of 16 Optional Files. Check we have 16 files in the framework.
I’m attempting to make the seventeenth Optional File and framework doesn’t caution me or toss any message.
We seem to be able to create an infinite number of auxiliary files. SAP recommends fewer records, but it doesn’t stop you if you don’t follow its rules. That’s what makes SAP so amazing.
What is the maximum amount of fields that an optional file can contain? In response, a creator mentioned in a well-known SAP blog that he might create the file using the largest 16 fields.
I made an effort to replicate the hard stop where SAP prohibits using more than 16 fields. As you can see in the image below, SAP didn’t weep when I added more than 25 fields to a list.
Additionally, check the length of these fields are in excess of 255 characters despite everything SAP didn’t stop. Seems to be, actually Auxiliary Record can have limitless fields. Could any master at any point affirm this?
Note: With respect to Drain Help Report, a record ought to just comprise of a couple of fields and, generally speaking, something like four fields.
There are such countless contemplations to be considered while making and utilizing Auxiliary Lists. Isn’t it minimal befuddling as well? Uplifting news. With the HANA advancement, we may in all likelihood never need Auxiliary Records in HANA Data set.
By and large, SAP HANA doesn’t need optional records for good inquiry execution. HANA data set store information in segment store naturally. Thus, every segment is a list in itself. SAP suggests utilizing Line store just in remarkable cases.
To diminish primary memory utilization, and to further develop embed execution all current non-special optional data set files on columnar tables are taken out during movement or don’t get made during establishment. Special files stay as they address an imperative on the table.
This is substantial for all AS ABAP frameworks from SAP NetWeaver 7.4 onwards!
This is our customary framework for all the above screen captures.
How about we rehash the inquiry once again. How might HANA Information base bear to dispose of Optional Lists?
Reply: HANA framework can examine the data set table at easing up speed as it is not quite the same as old style information bases. HANA data set tables are Segment based rather than Line situated in conventional data sets. This implies we don’t require files any longer. As currently referenced above, HANA data set section fields act as though we have physically made a list on each field of the table yet with practically no expense/cost/disadvantages of optional records as referenced above for conventional information base.
By removing files, we can reduce the amount of space that the data set takes up. For instance, auxiliary lists save 5% of the RAM that they would have used. It looks like the file pages at the back of the real books are removed, and the overall number of pages in a book is reduced. Additionally, you possess the extraordinary ability to read one million words every second and locate any word in a very little portion of the text. Therefore, you can locate the page number where that term appears in the book without referring to the lists at the back.
Does it mean, we can’t make Records in HANA Data set? Reply: Indeed, we can make Files in HANA Data set. HANA permits the Make Record order.
SAP master John Appleby says: Never make File in HANA. At the point when we make a table in HANA, it is, truth be told, making a bunch of arranged, compacted and connected lists. Therefore, optional records never further develop execution.
He says: “There is one situation when an optional file can further develop execution: when you have an inquiry which chooses a tiny measure of information from an extremely enormous table (or gathering of joined tables). In this example, making an optional file on the entirety of your sort sections can permit HANA to find the information quicker. Yet, this is what is going on – the straightforward exhortation is, never make files”.
As such, in specific dark situations where we find a presentation issue, an optional list can help. This is just in OLTP situations, where you have complex joins and just return a little subset of information from the table. The vast majority of situations won’t ever profit from a record. They occupy room and will slow embed activities, so ought to be stayed away from in HANA Data set.
Since we discovered that we can in fact make Files in HANA. What are the kinds of Lists in HANA? Reply: There are two kinds of Files in HANA.
1) Inverted Index and
2) Composite Index.
Inverted Index: Rearranged records allude to just a single section. Here, the list information is put away in inside memory structures that have a place with the separate segment.
Composite Index: Composite files allude to more than one segment. In the first place, the items these segments are assembled in an inward section, and a rearranged file is then made for this inside section.
We will examine insights regarding Rearranged/Composite Files in a different post.
To get such helpful and reasonable articles directly to your inbox, kindly Buy in. We regard your security and view safeguarding it in a serious way.
Does your Internet Dynpro UI Screen appear to be unique after EhP7.4 Overhaul? Taking one step back after EhP7.4..
We recently upgraded to EhP740, which brought with it a fresh appearance and feel. The BOXes, NEW Administrators, Worth Administrators, brilliant Google-like thoughts when writing the text, and so on are just incredible. In fact, even the user interface displays have cutting-edge highlights and mitigating appearances (SAP is really getting ready for cell phones, mists). In any case, the new UI highlights did not pique the interest of our business clientele, who are accustomed to the outdated UI panels. According to someone, anything that feels familiar always seems simpler.
Now taking one step back after EhP7.4, They requested the standard, worn out look and all buttons. I wonder, did we truly redesign or would we say we are making a stride back after overhaul?
Anyway, what all are absent in the UI screen after redesign?
The most unmistakable non-attendant according to our clients are: I) The section separator vertical line appears to have vanished. ii) The custom button appeared to be unique and accentuation and variety was a No. iii) The channel button is as of now not apparent.
Perhaps you’re wondering if SAP really removed the channel button. “No” is the response. A positive move has been taken by SAP. I acknowledge that its channel and sort usefulness at the segment level (as in Succeed) is really valuable. Who can convince our clients, anyway?
A picture speaks louder and more effectively than a thousand words.
Look how one of our UI screen looked before Upgrade.
Presently look at a similar screen after Redesign.
Have you noticed that the channel button and the upward line separators between parts are missing? Channels and sorts are at the section level, as I mentioned previously. Any section can be tapped to complete the channel and sort usefulness. Look at the personalized buttons as well.
Personally, I enjoy the fresh vibe. Is it fair to go back to a stage’s previous appearance? This could be a topic for discussion at a later time.
After little exploration one of our colleague sorted out that with Ehp7, we can add a boundaries in the Internet Dynpro application to get what our clients needed.
Let’s add the following parameter. WDTHEMEROOT sap_standard STRING Stylesheet URI
Look how the screen looks now. The screen is near the before overhaul look. Still the upward separator and channels are absent.
Add one more parameter. WDUIGUIDELINE GL11 WDR_APP_PROP_UIGUIDELINE UI Guideline
Presently we are totally one stage back. All that we had before overhaul is availble here.. Blissful Business Clients..
What does GL11 mean? F4 on the boundary esteem field uncovers there are two adaptations of UI Rule. GL11 is 1.1 adaptation and as a matter of course in EhP7 the UI form is 2.0 (GL20).
Setting GL11 resembles going one stage back. Do you concur?
Assuming you enjoyed it, if it’s not too much trouble, share it! Much obliged
NEW operator for internal tables and ABAP structures Can we declare NEW # for d_ref_struct as it appears above? (NEW Operator: Internal Tables and Structures) D_ref_struct would not recognize matnr and werks because it is an anonymous data object. The mistake is that for the operator “NEW,” no type can be inferred from the context.
The right way is to define d_ref_struct as structured object as shown below. NEW Operator – Structures and Internal Tables
* Example 1
TYPES: BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
DATA: d_ref_struct TYPE REF TO data. " Anonymous data object
d_ref_struct = new ty_marc( matnr = '165251' werks = '4030' ).
* Example 2
d_ref_struct = NEW #( matnr = '165251' werks = '4030' ).
Might we at any point proclaim NEW # as displayed above for d_ref_struct? D_ref_struct would not perceive matnr and werks because it is a mysterious information item. The mistake is that the administrator’s “NEW” setting does not yield any results.
The proper approach to describe d_ref_struct is as an organized object that is shown below.
ii) Structured data object
* Example 2
TYPES:
BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
DATA: d_ref_struct TYPE REF TO ty_marc. " Structured data object
d_ref_struct = NEW #( matnr = '165251' werks = '4030' ).
When “#” succeeds NEW, it means the object ref in the Left Hand Side determines the type.
2. For Internal Tables i) Anonymous data object
* Example 1
TYPES:
BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
DATA: d_ref_tab TYPE REF TO data. " Anonymous data object
d_ref_tab = NEW ty_marc( ( matnr = '165251' werks = '4030')
( matnr = '165251' werks = '5172') ).
Going by the case of designs displayed above before inside table, this model 1 of inward table looks right. In any case, SAP could do without it..
What turned out badly? NEW ty_marc( ) is pertinent for structure. In this way, can’t switch over completely to interior table.
Lets attempt once more by proclaiming a table kind.
* Example 1 -- first retry
TYPES:
BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
TYPES: tt_marc TYPE TABLE OF ty_marc.
DATA: d_ref_tab TYPE REF TO data. " Anonymous data object
d_ref_tab = NEW tt_marc( ( matnr = '165251' werks = '4030')
( matnr = '165251' werks = '5172') ).
Here we rolled out two improvements. I) Table Sort tt_marc is characterized. ii) NEW tt_marc is utilized rather than NEW ty_marc
Yet, still the framework gives mistake “A worth of the nonexclusive kind “TT_MARC” can’t be built”.
How about we offer another chance. Here we will add only 3 watchwords “WITH DEFAULT KEY” in Table Kind announcement.
* Example 1 -- second retry
TYPES:
BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
TYPES: tt_marc TYPE TABLE OF ty_marc WITH DEFAULT KEY.
DATA: d_ref_tab TYPE REF TO data. " Anonymous data object
d_ref_tab = NEW tt_marc( ( matnr = '165251' werks = '4030')
( matnr = '165251' werks = '5172') ).
Bingooo!!!! WITH DEFAULT KEY got the job done. Unknown information object is currently an inner table.
The following is one more guide to characterize and populate inward table with mysterious item.
* Example 2
TYPES:
begin of ty_marc,
matnr type matnr,
werks type werks_d,
end of ty_marc.
DATA: d_ref_tab TYPE TABLE OF REF TO DATA, " Anonymous data object
wa_marc TYPE ty_marc.
SELECT matnr werks UP TO 10 ROWS FROM marc INTO wa_marc.
APPEND NEW ty_marc( wa_marc ) to d_ref_tab. " Object is created here
The substance of the line is alloted to the information object. The item is made at the assertion Add and the NEW information reference is affixed straightforwardly to an inward table with the suitable line type. The outcome is a table that references generally new unknown information objects of 10 lines.
ii) Structured data object
* Example 3
TYPES:
BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
DATA: d_ref_tab TYPE STANDARD TABLE OF REF TO ty_marc, "Structured object
wa_marc TYPE ty_marc.
SELECT matnr werks UP TO 10 ROWS FROM marc INTO wa_marc.
APPEND NEW #( wa_marc ) TO d_ref_tab.
ENDSELECT.
Trust with the above models and pieces, you would be in the situation to mess with NEW Administrator. In our next post we would investigate the Worth Administrator.
ABAP is a new operator single value. We shown in the last post that one of the enhanced features in EhP7 is NEW Administrator. In this case, NEW Operator – Single Value for All Data Types or NEW Administrator – Single Incentive for All Information Types would be used.
NEW Operator: One Value for All Data Types for the New Administrator
I) At any one time, an articulation that has been identified for an information item may either contain or be a constructor articulation.
ii) When a constructor articulation is doled out to a reference variable utilizing NEW, this variable focuses to the underlying item all along. This implies that the first reference is as of now not accessible involving the objective variable in the articulation.
* Example 1
PARAMETERS input(10) TYPE c DEFAULT 'EhP7'.
DATA d_ref TYPE REF TO string.
d_ref = NEW string( 'Welcome' && ` ` && input ).
WRITE:/ d_ref->*.
NEW operator constructs an anonymous data object of the type string, whose value is determined using a string expression. Note: The chaining operator && concatenates two operands in a string expression as a character string.
* Example 2
TYPES: BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
DATA: d_ref TYPE STANDARD TABLE OF REF TO ty_marc,
wa_marc TYPE ty_marc.
SELECT SINGLE matnr werks FROM marc INTO wa_marc.
APPEND wa_marc TO d_ref. " Syntax Error
The above statement APPEND wa_marc to d_ref would give syntax error: “WA_MARC” cannot be converted to the line type of “D_REF”.
Instead if we use the NEW Operator as shown below, the content of the work area can be assigned to the data object d_ref.
APPEND NEW #( wa_marc ) TO d_ref.
Following the SELECT, a structured, enigmatic information object is created for the selected column. This information object receives the line’s substance. The article is written in the assertion’s general articulation position. Simply attach the NEW information reference to an inner table using the appropriate column type. A table referencing mostly new, enigmatic information objects is the result.
As mentioned in a previous post, the article reference on the left-hand side determines the sort when “#” comes after NEW.
These are basic models. In resulting posts, we would attempt to investigate more perplexing and genuine undertaking situations. Kindly look at the following post on structures and inner tables in NEW Administrator.
Introduction to SAP EhP7 More than 750 business capabilities are included in SAP Upgrade Bundle 7 for SAP ERP 6.0, according to SAP news. Information maturing objects, MRP runs, and SAP Fiori are the main new components. The primary upgrade package for both the SAP HANA data set and the traditional validated data sets is SAP EhP7.
Being a straightforward ABAP engineer, I was curious to know how this 7.4 overhaul will affect an ABAPer. After reviewing the sap discharge reports and researching the framework, I have tried to document the advancements that ABAPers like me would find interesting.
Also, NEW and Worth Administrators are the main elements in SAP EhP7, which the ABAPer would utilize routinely.
NEW – Instance Operator i) NEW – Initial Value for All Types ii) NEW – Single Value for All Data Types iii) NEW – Structures iv) NEW – Internal Tables v) NEW – Classes
VALUE – Value Operator i) VALUE – Initial Value for All Types ii) VALUE – Structures iii) VALUE – Internal Tables
In this post, I would like to show some usage of NEW Operators for Initial Value for All Types.
* Type declaration
TYPES: BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
* Type Ref To
DATA o_ref TYPE REF TO ty_marc.
* Example 1
* Instantiate the object
o_ref = NEW ty_marc( ).
* Usage demo
SELECT SINGLE matnr werks FROM marc INTO o_ref->*.
IF sy-subrc EQ 0.
* Displaying the fields as we used to do earlier
WRITE:/ o_ref->*-matnr, o_ref->*-werks.
ENDIF.
Please note NEW <TYPE>( ) is the syntax to instantiate any object.
* Example 2
* Instantiate the object using #
o_ref = NEW #( ).
* Usage demo
SELECT SINGLE matnr werks FROM marc INTO o_ref->*.
IF sy-subrc EQ 0.
* Displaying the fields as we used to do earlier
WRITE:/ o_ref->*-matnr, o_ref->*-werks.
ENDIF.
Note NEW # () if it’s not too much trouble. It is implied that the article ref on the left determines the sort when “#” comes after NEW.
This brief post aims to raise your awareness of the new linguistic framework. The capabilities of the two constructor articulations mentioned above are comparable. In future postings, I’ll go into greater detail about NEW and Worth admins.
Oh no! Are you thinking about how the outcome might appear before I shut down? The same old thing. The yield is same to that of SAP EhP7. The yield show has not been redesigned.
OLE Excel in ABAP 7.4: An All-Inclusive Guide for SAP Developers Let’s examine the SAP HANA: Opportunities and Challenges ALV Report. Everyone has been being cleared out by the HANA Tempest. According to a September 2017 SAP study, there were more than 1000 clients using S/4HANA at the time. Therefore, all professionals working on SAP would need to navigate the HANA waters tomorrow, if not immediately. ABAPers, who program ALV Reports every other week, will replace the SAP Professionals. Have you considered the relative advantages and disadvantages of planning an ALV report in SAP using HANA as the suite and data set?
ALV Reports are the Cockroaches of SAP world, which would survive every evolution.
The ALV’s roots, establishment, or starting place are the same in HANA World as they were in traditional data sets, such Choice SCREEN. Unfortunately, when we observe this, we frequently come to some conclusions. Checkboxes, radio buttons, choice screen blocks, and other features must be present on the screen. This is unfortunate since, on the one hand, Fiori Platforms feature stunning and dynamic screens with apps that improve Client Experience (UX) by using SAP UI5, and on the other, we have the standard ALV.
Rather cribbing about it, we want to recall that clients (actually) request ALV reports like standard T-Code yield for example ME2N (citing on the grounds that that was the prerequisite I got). Afterall everything isn’t about client experience. Complex business needs likewise get some weight.
Regardless, whether you are attempting to learn Fiori or SAPUI5, ALV reports can’t be supplanted. In this way, likewise begin investigating the new way you can make the ALVs.
How might we make our (ABAPers) lives merry and fascinating? Add HANA in with the general mish-mash and what you get is simpler to code (well not really) and all the more critically more prominent improvement in the exhibition.
The improvement in execution is exclusively credited to one thing that is the idea called “Code Push Down” or “Code to Information (Data set) Worldview”. Heard it anyplace? Try not to say No. We are at the twentieth part in our HANA ABAP Series.
What is Code Push Down? (ALV Report On SAP HANA – Opportunities And Challenges)
Here we have a tipping point. One can go for the strategy for utilizing Discs View alongside AMDP (if vital) or go with IDA. Utilizing IDA is much more straightforward than AMDP, yet possibly one can’t be a swap for the other. They play their own parts to play. In the following article, I will cover the distinctions and benefits of IDA against Albums.
Prior to looking down it would be smart to discover somewhat more about AMDP (ABAP Oversaw Data set System) and IDA (Coordinated Information Access).
So for ALV in HANA, we have the accompanying:
Selection Screen
Data is ready in CDS +/- AMDP
What next? Just connect them.
3. Applying selection screen criteria into CDS view entries.
The third step is a piece precarious. We again have various open doors here.
3.1 Either pass all the determination screen channels into AMDP ( NOT Compact discs View as a result of the way that Cds Perspectives are defined and can’t take more than one incentive for a solitary field and choice screen of the ALV report has select choices which are in range tables)
OR
3.2 Get every one of the passages from Compact discs View into your Application Layer and afterward continue with regular coding practice.
At this point, experienced ABAPers would agree that that first methodology (AMDP) would do every one of the positive qualities regarding execution.
Now we have narrowed down to:
Choice Screen
Information is prepared in Discs +/ – AMDP
Applying choice screen measures into Discs view sections utilizing AMDP and bringing just required passages into AS layer and continuing with regular SALV manufacturing plant class utilizing Oh no.
Technical Points:
Conversion of SELECT-OPTIONS into Dynamic “WHERE CLAUSE”: When the standard determination screen is constructed, the main obstacle is incorporate the select choices into AMDP. To accomplish that we have the accompanying code piece:
DATA(lv_where) = cl_shdb_seltab=>combine_seltabs(
it_named_seltabs = VALUE #(
( name = 'MATNR' dref = REF #( so_matnr[] ) )
( name = 'EBELN' dref = REF #( so_ebeln[] ) )
) ).
Trust you can grasp the above code. Else, the beneath elective for a similar activity can assist you with bettering.
cl_shdb_seltab=>combine_seltabs(
EXPORTING
it_named_seltabs = VALUE #(
( name = 'MATNR' dref = REF #( so_matnr[] ) )
( name = 'EBELN' dref = REF #( so_ebeln[] ) )
)
RECEIVING
rv_where = DATA(lv_where) ).
2. Using Dynamic where clause in AMDP: The following test is to utilize the where condition. There is an element in SAP AS 7.40 and higher of “APPLY Channel”. The lv_where statement worked above is passed to AMDP technique boundary ip_filters.
Conclusion: ALV Report On SAP HANA – Opportunities And Challenges
Making the most of HANA DB and HANA instruments like HANA Studio we enjoy following benefits ( opportunity ):
Since there is code push down and a greater portion of the information bringing is completed at HANA DB alongside collections, totals, and midpoints, the execution was further developed.
Powerful on-the-fly custom naming of the ALV result fields [may be completed with CDS].
Dynamic SELECT questions in AMDP based on the data provided by the client and the content stored in the database [for example, if the database contains columns for City and Country, we may use the CASE articulation to conclude whether or not the input city provided by the client is the capital].
Get rid of it for every section. [Instead, use internal joins]. Have we just found ourselves in yet another predicament?.
The opposite side of the story, challenges:
At the point when we go with Discs Perspectives to extricate information into AS layer, then, at that point, there might be still some presentation issues (despite the fact that Cds relics would in any case give great exhibitions, still some unacceptable utilization of Cds can blow up).
Kindly trust that the following article will get a brief look at the genuine code to exhibit all the abovementioned and IDA. Along these lines, if it’s not too much trouble, remain tuned and get yourself HANA-tized.
Now we want to hear from you.
Kindly leave your input, stories and speedy remarks beneath.