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.
Creating dynamic internal table in ABAP In one of our post, we showed the use of Dynamic Where Condition . In this article, Creating Dynamic Internal Table we would show one out of the numerous ways of creating Dynamic Inward Table and show it in ALV yield.
Let’s assume you have a necessity where you need to show a report to demonstrate one Material is available in the number of Plants. Say your feedback material ‘M1’ is available in two plants say ‘P1’ and ‘P2’. So the result ALV report ought to show just two three segments, M1, P1 and P2. Let’s assume you have another material ‘M2’ which is available in 5 plants ‘P1’, ‘P2’, ‘P3’, ‘P4’ and ‘P5’. Then the result table would have six segments. M1, P1, P2, P3, P4 and P5.
Make a note, the quantity of sections are changing in view of the information. Allow us to see a genuine model. Creating Dynamic Internal Table.
Above screen capture shows that Material ‘100522’ is available in two plants. Our ALV would show as underneath.
Check the MARC screen capture, Material ‘100567’ is available in four plants. Our ALV would show as beneath.
Did you see, the quantity of segments are changing powerfully according to the information? This should be possible in numerous ways, yet the most helpful way is to make dynamic design/inner table and show it.
Capability Module ‘DDIF_FIELDINFO_GET’ would assist us with getting table field data. Really take a look at the code beneath, we are supplanting ‘MARC-WERKS’ field name, with the genuine Plant number. This was only a particular undertaking prerequisite. You could have another prerequisite.
Material is a decent segment yet Plants are dynamic in view of information from MARC. Check we are circling through the interior table and utilizing FM ‘DDIF_FIELDINFO_GET’ to decide and populate field index data.
When we have the field index (i_fcat), we want to construct the unique inside table with the not entirely set in stone by i_fcat. For this model, we are utilizing technique ‘CREATE_DYNAMIC_TABLE’ of class CL_ALV_TABLE_CREATE.
———————————————————–
Updated: 19th Dec 2017 – Feedback from Steve
Consider adding: I_LENGTH_IN_BYTE = ‘X’ to the CALL METHOD cl_alv_table_create=>create_dynamic_table statement I had a problem where I needed the dynamic table to create a p(7)/3, without that additional statement it calculates a P(4)/3.
———————————————————–
The under two stages are the main ones. Here we are allocating the unique construction to the <field-symbol> table and <field-symbol> workspace which would be utilized later to show the ALV.
* Assign the structure of dynamic table to field symbol
ASSIGN i_dynamic_table->* TO <i_dyn_table>.
* Create the dynamic work area
CREATE DATA wa_dyn_line LIKE LINE OF <i_dyn_table>.
ASSIGN wa_dyn_line->* TO <wa_dyn>.
There is some mathematic done to stamp ‘X’ for the segment where the material is available. So don’t be confounded. In troubleshooting, that’s what it shows despite the fact that MATNR has 18 characters, the unique table show 36 (simply the twofold). Same with Plant, it shows 8 rather than 4. Thus, this is the sort of thing you need to check before you put your information.
Whenever you have populated the information in the powerful inside table, showing information in ALV is a cake walk. Simply utilize the FM ‘REUSE_ALV_GRID_DISPLAY’.
Really look at the code conduct in Troubleshooting mode”
Check I_FCAT table, it has 4 columns of fields. This implies, the unique interior table would have 4 segments. One fixed for Material and 3 dynamic for plants.
This is the class and technique which really makes the powerful inward table.
Check I_DYNAMIC_TABLE, it has now 3 segments for plants. This is the construction you want. Presently make the inward table and workspace and populate your last information and show it.
Allow us to see, how the result would look like when we input 3 materials which are accessible in different plants.
Check, the quantity of plant segments are the association of the multitude of three materials. Isn’t it dynamic?
Kindly track down the functioning system for the above prerequisite here.
REPORT elearning. *----------------------------------------------------------------------* * Created by : eLearning (https://eLearning.com/) * * Purpose : Program to show Dynamic Internal table * * Visit https://eLearning.com/ for SAP Technical Tips & Solutions * *----------------------------------------------------------------------* *---------------------------------------------------------------------* * POOLS * *---------------------------------------------------------------------* TYPE-POOLS: slis. *---------------------------------------------------------------------* * TABLES * *---------------------------------------------------------------------* TABLES: mara. *---------------------------------------------------------------------* * TYPES *---------------------------------------------------------------------* TYPES: BEGIN OF x_data, matnr TYPE matnr, werks TYPE werks_d, END OF x_data. *---------------------------------------------------------------------* * DATA * *---------------------------------------------------------------------* DATA: * Internal tables i_data TYPE STANDARD TABLE OF x_data, i_data_temp TYPE STANDARD TABLE OF x_data, i_fcat TYPE lvc_t_fcat, i_dynamic_table TYPE REF TO data, i_plant TYPE STANDARD TABLE OF x_plant, i_fieldcat TYPE slis_t_fieldcat_alv,
* Work ara wa_fcat TYPE lvc_s_fcat, wa_dyn_line TYPE REF TO data, wa_plant TYPE x_plant, wa_data TYPE x_data,
* Variable v_field_name TYPE fieldname, v_tabix TYPE sytabix, v_fieldname TYPE fieldname, v_seltext TYPE scrtext_l. *---------------------------------------------------------------------* * Field Symbols * *---------------------------------------------------------------------* FIELD-SYMBOLS: <i_dyn_table> TYPE STANDARD TABLE, <i_final_table> TYPE STANDARD TABLE, <wa_dyn> TYPE any, <wa_final> TYPE any. *---------------------------------------------------------------------* * SELECTION SCREEN * *---------------------------------------------------------------------* SELECT-OPTIONS: s_matnr FOR mara-matnr. *---------------------------------------------------------------------* * INITIALIZATION * *---------------------------------------------------------------------* INITIALIZATION. * Select data *---------------------------------------------------------------------* * START-OF-SELECTION. * *---------------------------------------------------------------------* START-OF-SELECTION. PERFORM sub_slect_data.
*---------------------------------------------------------------------* * END-OF-SELECTION. * *---------------------------------------------------------------------* END-OF-SELECTION. * Populate the dynamic columns needed for each run PERFORM sub_populate_catlog.
* Build the dynamic internal table PERFORM sub_build_int_table.
* Build ALF Field Catalog information PERFORM sub_alv_field_cat.
* Display data PERFORM sub_display_data.
*---------------------------------------------------------------------* * SUB ROUTINES * *---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form SUB_SLECT_DATA *&---------------------------------------------------------------------* FORM sub_slect_data .
SELECT matnr werks INTO TABLE i_data FROM marc WHERE matnr IN s_matnr. IF sy-subrc EQ 0. SORT i_data BY matnr.
i_data_temp[] = i_data[]. SORT i_data_temp BY werks. DELETE ADJACENT DUPLICATES FROM i_data_temp COMPARING werks. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form SUB_POPULATE_CATLOG *&---------------------------------------------------------------------* FORM sub_populate_catlog . v_field_name = 'MATNR'. * There is one Material column PERFORM sub_pop_field_catlog USING v_field_name.
v_field_name = 'WERKS'. * There would be 'N' number of dynamic Plant columns * depending on the material and plants combination LOOP AT i_data_temp INTO wa_data. PERFORM sub_pop_field_catlog USING v_field_name. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form SUB_POP_FIELD_CATLOG *&---------------------------------------------------------------------* FORM sub_pop_field_catlog USING p_l_field_name TYPE fieldname.
DATA: l_i_dfies TYPE STANDARD TABLE OF dfies, l_wa_dfies TYPE dfies.
CLEAR l_wa_dfies. READ TABLE l_i_dfies INTO l_wa_dfies INDEX 1. CLEAR wa_fcat. * Since we want the Plant number to be the header text * Replacing the field name with actual plant value IF v_field_name = 'WERKS'. l_wa_dfies-fieldname = wa_data-werks. ENDIF.
MOVE-CORRESPONDING l_wa_dfies TO wa_fcat. APPEND wa_fcat TO i_fcat. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form SUB_BUILD_INT_TABLE *&---------------------------------------------------------------------* FORM sub_build_int_table .
* Prepare the dynamic internal table with required columns of each run CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = i_fcat IMPORTING ep_table = i_dynamic_table EXCEPTIONS generate_subpool_dir_full = 1 OTHERS = 2. * Assign the structure of dynamic table to field symbol ASSIGN i_dynamic_table->* TO <i_dyn_table>.
* Create the dynamic work area CREATE DATA wa_dyn_line LIKE LINE OF <i_dyn_table>. ASSIGN wa_dyn_line->* TO <wa_dyn>.
ENDFORM. *&---------------------------------------------------------------------* *& Form SUB_ALV_FIELD_CAT *&---------------------------------------------------------------------* FORM sub_alv_field_cat .
* Build field catalog for Material PERFORM sub_fill_alv_field_cat USING 'MATNR' '<I_DYN_TABLE>' 'L' 'Material Number' 36.
* Number of Plant columns would be dynamic for Plants LOOP AT i_data_temp INTO wa_data.
PERFORM sub_fill_alv_field_cat USING v_fieldname '<I_DYN_TABLE>' 'L' v_seltext 8.
ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form SUB_FILL_ALV_FIELD_CAT *&---------------------------------------------------------------------* FORM sub_fill_alv_field_cat USING p_fldnam TYPE fieldname p_tabnam TYPE tabname p_justif TYPE char1 p_seltext TYPE dd03p-scrtext_l p_outlen TYPE i.
*&---------------------------------------------------------------------* *& Form SUB_DISPLAY_DATA *&---------------------------------------------------------------------* FORM sub_display_data .
DATA: l_count TYPE i, l_factor TYPE i, l_wa_layout TYPE slis_layout_alv.
LOOP AT i_data INTO wa_data.
CLEAR: l_factor, l_count.
READ TABLE i_data_temp WITH KEY werks = wa_data-werks TRANSPORTING NO FIELDS BINARY SEARCH. IF sy-subrc EQ 0.
If you have any desire to get such commonsense changes and deceives directly to your inbox, kindly Buy in. We regard your security and view safeguarding it in a serious way.
In the event that you loved this post, kindly hit the offer buttons. If it’s not too much trouble, similar to us at facebook and support us. Assuming that you have any ideas, analysis, remarks or questions, kindly remark or connect with us.
SQL Tips: Dynamic WHERE Condition in Database Queries Let’s begin by discussing how to use dynamic where conditions in database queries. We desire Dynamic Where Condition for data set (DB) inquiries, but there aren’t many changes. Importance: Your software may determine during runtime which fields in the database table should be used for the DB query. To support such Dynamic Where Conditions, we can write our own unique code. In any case, we are aware of the effort and suffering required to write such a code. Thankfully, we can fulfill the requirement by using the Standard SAP capability module CRS_CREATE_WHERE_CONDITION. Using dynamic where clauses in database queries
Test Model:
We should think about it because we have a program that can comprehend part of the reasoning. Finally, it concludes that, in light of the fields MATNR (Material Number) and MTART (Material Sort), it should do an inquiry on the Data Set table MARA. The question can be asked in a few other possible fields, and the selection will be decided at runtime. Until run time, the table fields and their comparison values are unknown. Therefore, a dynamic where condition is what we truly want for the data set inquiry. Under such circumstances, you may choose to look at every possible combination of fields that could be used in the where condition and compose your custom code to produce a Dynamic Where Condition or you can simply utilize a Capability Module (FM) which will finish the work you.
We will examine what is going on thinking about a program, with a determination screen having both the fields MATNR and MTART. (Allow us to accept these two fields and their comparing values won’t be accessible until runtime). If it’s not too much trouble, note, this program is composed to make sense of the Dynamic Where Condition. In real venture, you wouldn’t have the boundaries in determination screen. You may very well know the table and field name and values in those fields would be populated at runtime.
For straightforwardness, we have made these fields as a component of determination screen to populate our Dynamic Where Condition.
* Types
TYPES: BEGIN OF x_mara,
matnr TYPE matnr, "Material Number
mtart TYPE mtart, "Material Type
END OF x_mara.
DATA:
* Internal table
l_i_range TYPE STANDARD TABLE OF crmselstr,
l_i_output TYPE STANDARD TABLE OF mcondition,
l_i_mara TYPE STANDARD TABLE OF x_mara,
* Work area
l_wa_range TYPE crmselstr,
* Variable
v_matnr TYPE mara-matnr,
v_mtart TYPE mara-mtart.
* Selection Screen
SELECT-OPTIONS: s_matnr FOR v_matnr,
s_mtart FOR v_mtart.
* For Select Option 1
LOOP AT s_matnr. "Looping to get multiple (single) values
l_wa_range-table = 'MARA'. "Name of the DB table
l_wa_range-field = 'MATNR'. "Field name the user has selected
l_wa_range-sign = s_matnr-sign. "Sign
l_wa_range-option = s_matnr-option."option
l_wa_range-low = s_matnr-low. "Lower Value
l_wa_range-high = s_matnr-high. "Higher Value
APPEND l_wa_range TO l_i_range.
ENDLOOP..
* For Select Option 2
LOOP AT s_mtart. "Looping to get multiple (single) values
CLEAR l_wa_range.
l_wa_range-table = 'MARA'. "Name of the DB table
l_wa_range-field = 'MTART'. "Field name the user has selected
l_wa_range-sign = s_mtart-sign. "Sign
l_wa_range-option = s_mtart-option. "option
l_wa_range-low = s_mtart-low. "Lower Value
l_wa_range-high = s_mtart-high. "Higher Value
APPEND l_wa_range TO l_i_range.
ENDLOOP.
IF NOT l_i_range[] IS INITIAL.
* Call the FM to create the Dynamic Where condition
CALL FUNCTION 'CRS_CREATE_WHERE_CONDITION'
TABLES
ti_range = l_i_range
to_cond = l_i_output
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
IF sy-subrc = 0.
* Special way to write the query
SELECT matnr "Material Number
mtart "Material Type
FROM mara
INTO TABLE l_i_mara
WHERE (l_i_output).
IF sy-subrc = 0.
ENDIF.
ENDIF. "IF sy-subrc = 0: SELECT matnr mtart
ENDIF. "IF NOT l_i_range[] IS INITIAL.
Please note above:The Dynamic Where Condition table has to be put in brackets during the SELECT statement
WHERE (l_i_output).
Let us check the values in debug mode.
In choice screen we gave two qualities to material number field and one worth to material sort.
Check the range internal table l_i_range has data from two fields.
Function module CRS_CREATE_WHERE_CONDITION smartly converts the data to Dynamic Where Condition in internal table l_i_output. Isn’t this cool?
Why would it be wise for us to set aside time to write code to put up our own Dynamic Where Condition at the moment when SAP has provided this FM? You now know which FM to contact the next time you need a Dynamic Where Proviso..
Only a few years ago, we explained how to use a scratchpad to investigate the Spring Up Screen. Please take a look at this instructional exercise on Spring Up Troubleshooting Stunt. ROBO [Pop Up Troubleshooting By Notebook File] is the moniker I gave it. Simply ROBO. Don’t ask me what it means, please. Let’s get started with ROBO 2.0 Pop Up Debugging..
In this article, Pop Up Debugging [ROBO 2.0] we will attempt to make sense of another methods of Spring Up Troubleshooting utilizing SAP Easy route
ROBO 2.0 [PopUp Debugging by SAP Shortcut ]
ROBO Chitti [ Pop Up Debugging by SAP ShortcutwithMore Ease ]
1. ROBO 2.0 [ Pop Up Debugging By SAP Shortcut ]
We accept, the greater part of us are familiar with Spring Up Troubleshooting with SAP Easy route. In any case, on the off chance that you don’t know, let me tell the best way to make and utilize SAP Easy route to Troubleshoot SAP Spring Up. This is my ROBO 2.0 (nothing official about it) :P.
SAP Shortcut creation Steps as below.
You can create shortcut from any screen
Type = ‘System Command’; Transcation = ‘/H’; Location = ‘Desktop’ (wherever you want)
Presently we will perceive how might we utilize a similar SAP Easy route to Troubleshoot the Spring Up!.
Step:1 [ I have a screen where I have to debug the Pop Up ]
Step:2 I limited every one of my applications by utilizing Window + D alternate route then I held and hauled the SAP alternate way which I made in above advances and moved or explored to Drain GUI Application that was at that point opened in Taskbar Level for example as beneath
That’s it.
2. ROBO CHITTI [ Pop Up Debugging by Shortcut with more Ease ]
We created a SAP alternate route up till this point, moved out of the work area, dropped something comparable on Spring Up, and fixed it. There is an issue with restricting the number of meetings that may be held, figuring out the quickest way, and then dragging it to the spring screen. If everything else is equal, we can make the interaction easier by sticking the GUI alternate path to the taskbar. The simplest way to nail any application to the taskbar is to right-tap it and pin it to the taskbar. You can also use other methods you are familiar with. When the other option isn’t working, launch the SAP GUI application that has to be looked into. This time it is easier.
Simply drag the alternate way you have stuck to the spring up screen.
I want to believe that you previously sorted out the benefit of this technique. Don’t bother limiting all applications [with Window + D] to move the SAP Easy route on to Spring Up and don’t bother agonizing over exploring to Drain GUI Application by holding the alternate way. Just we can drag a similar easy route (Upwards) from Errand Bar and Drop it on to ‘Spring Up.’
I have no doubt that many of you were somewhat aware of both of these methods. Nevertheless, because nobody can truly know, we genuinely thought about posting this because it might enlighten some young or old minds..
I want to share a simple trick to make use of a BAdI and disable Hold button in Purchase Order Creation (t-code ME21N). Let’s go deep into the Easy Trick to Disable Hold Button in PO ME21N using BADI.
On initial step, ensure Keep button actually exists. Check the Hold featured in yellow.
Open BAdI Developer through T-Code SE19. On BAdI Developer screen, pick Exemplary BAdI, on BAdI name segment fill ME_HOLD_PO and afterward click on Make Impl. button. In this step, we duplicate default standard BAdI which is ME_HOLD_PO into our BAdI name.
Input execution name as our BAdI name, remember to begin your BAdI Execution name with Z or Y, for instance I utilized ZHOLDPO name for my BAdI name.
Input some text for the BAdI Execution depiction.
Remember your BAdI Execution for a bundle and dole out into a vehicle demand to ship it to Quality and consequently to Creation framework.
Click on Point of interaction Tab, and afterward Double tap on Technique IS_ALLOWED.
It opens the ABAP Supervisor. To see existing boundary, simply click signature button.
We can see boundary CH_ALLOWED. We want to utilize this boundary to cripple Hold Button in the PO. Put your code among strategy and endmethod. We have hard-coded CH_ALLOWED with invalid worth. It implies Hold button won’t exist any longer. Remember to Enact your BAdI Execution.
Simply press enter on spring up, this spring up seems on the grounds that there is one more article with inert status.
Simply ensure your code is enacted. Click back on back button.
In any case, BAdI status is as yet latent, and Runtime Conduct is “Execution won’t be called”. You can definitely relax, it implies BAdI was not executed as expected. We simply have to Enact the BAdI Execution here.
After enactment of BAdI Execution, status will be Dynamic and Runtime Conduct will be “Execution will be called”.
Last step. How about we approve our adjustment of the PO screen. Bingo!! The Hold button which you found in the absolute first screen capture, doesn’t exist. Presently, go an illuminate the business group who requested it. Your task is finished for the afternoon.
This is a basic arrangement once you track down it. In any case, when you don’t have a clue about the BAdI name, you need to scramble around and google. Easy Trick to Disable Hold Button in PO ME21N using BADI.
The SAP Debugger New Tool for Memory Stack is a powerful new feature that makes debugging in SAP ABAP more efficient and developer-friendly. Whether you’re trying to retrieve hidden field values from a transaction or access global variables during runtime, this tool gives you a clear path through the memory stack. In this quick guide, you’ll learn how to use the SAP Debugger’s new memory stack tool in just 5 steps — perfect for solving those tricky BADI and client exit challenges.
In this article, Fetching Data from Memory Stack Using New Tool (in Debugger), we will gain proficiency with a short and straightforward stunt to get to separate qualities standard exchange code.
Essentially, we would take advantage of the Memory Stack at Run-Time involving the New Apparatus in Debugger. Assuming in any meeting somebody asks you, do you realize Memory Stack Programming? Subsequent to going through this article, your response ought to be a major certain certifiable.
Following are the steps that need to be followed:
Get the program name and field information from the screen (utilizing F1)
Add a breakpoint in the exit/BADI
Execute the exchange and actually look at the worth at runtime utilizing New Apparatus (Devices – > Exceptional Instrument -> Stacked Projects)
Add code in the exit/BADI for getting information from the screen field
Stranger than fiction can be the truth. I’ll give you a very simple constant-use model. In SAP, there is a mechanism to include one-time seller details when submitting a purchase request. The length of the approval PINCODE must be included.
We were involving Actually look at strategy for BADI ME_PROCESS_PO_CUST for approval in PO. Yet, found that the location subtleties were not open in the BADI.
We followed the 4 stages referenced previously. We found the program name and field information.
Added the debugger and executed the exchange. In the debugger apparatus, go to New Device choice.
Alert: In the event that your debugger takes you to the Standard Tab naturally, you wouldn’t view as the “New Apparatus”. Try not to overreact. Simply click Work area 1 or Work area 2 or Work area 3 and New Device would show up for your administration.
Go to Stacked Projects choice in Extraordinary Devices.
Select Worldwide Information tab where we will actually want to see every one of the worldwide factors of each program.
Allow us now to track down the program and field for Address information.
Definitely, we got the ADDR1_DATA values. So presently we arrived at the last step – the code :).
FIELD-SYMBOLS:<fs1> TYPE any.
* Make the system know from which Program we need the data DATA:post_code(40) TYPE c VALUE '(SAPLSZA1)ADDR1_DATA-POST_CODE1'.
* Assign the value to a field system ASSIGN (post_code) TO <fs1>.
IF <fs1> IS ASSIGNED. * Do your validation IF strlen( <fs1> ) NE '6'. MESSAGE 'Postal Code should be of length 6.' TYPE 'E'. ENDIF.
ENDIF.
Fundamentally, we just dove profoundly into the memory stack at the run-time and searched for all projects that were stacked in the framework for consummation of the specific exchange. Utilizing the New Instrument, we tracked down the Worldwide Information. When you have the Worldwide Information, you can simply get that information in your program utilizing Field Image.
Trust you like this stunt. This is a basic arrangement which we want to do in each venture. On the off chance that you are a novice on SAP ABAP, bookmark this article. You would require this for your most memorable Memory Stack Programming.
You can execute this equivalent stunt to get any worldwide information like table, structures, factors, objects and so forth.
Note: There is a restriction. On the off chance that the variable, workspace, table and so forth are NOT announced as Worldwide on the stacked projects, then, at that point, we Can’t recover its worth utilizing the above technique.