SAP & Oracle partner and support companies

Loading

Archives June 2025

SAP

Dynamic Where Condition usage in Database queries

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.

You can also read for:- list of data types in sap abap

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.

Dynamic ABAP

Check the range internal table l_i_range has data from two fields.

Dynamic Where Condition

Function module CRS_CREATE_WHERE_CONDITION smartly converts the data to Dynamic Where Condition in internal table l_i_output.  Isn’t this cool? 

Dynamic Where Condition

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..

Much thanks for your time!!

YOU MAY BE INTERESTED IN

How to Convert JSON Data Structure to ABAP Structure without ABAP Code or SE11?

Best Practices for SAP ABAP Development: A Comprehensive Guide

A Comprehensive Guide to SAP ABAP Training Online

SAP

Pop Up Debugging [ROBO 2.0]

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

  1. ROBO 2.0 [PopUp Debugging by SAP Shortcut ]
  2. ROBO Chitti [ Pop Up Debugging by SAP Shortcut with More 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.

You can also read for:- Advance SAPUI5 – Integration of Google Maps JavaScript API with SAPUI5 App

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..

YOU MAY LIKE THIS

10 Real-World SAP ABAP Programming Examples (with Code!

Building custom SAP Fiori applications for improved sales efficiency

Back-End Development

SAP

Easy Trick to Disable Hold Button in PO (ME21N) using BADI

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.

YOU MAY LIKE THIS

How to check your custom ABAP code for SAP BTP ABAP Environment

10 Real-World SAP ABAP Programming Examples (with Code!)

Number Range tcode in SAP

Create and Consume Business Add-in(BAdI) in ABAP

SAP

Quick Guide: SAP Debugger New Tool for Memory Stack

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.

This image has an empty alt attribute; its file name is image001.png

Added the debugger and executed the exchange. In the debugger apparatus, go to New Device choice.

new tool in debugger

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.

This image has an empty alt attribute; its file name is newtool.jpg

Go to Stacked Projects choice in Extraordinary Devices.

Loaded Program

Select Worldwide Information tab where we will actually want to see every one of the worldwide factors of each program.

New Tool in SAP

Allow us now to track down the program and field for Address information.

This image has an empty alt attribute; its file name is image007.png

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.

YOU MAY BE INTERESTED IN

Future of ABAP on Cloud

ABAP Development Environment in the Cloud

ALE and IDoc in SAP ABAP: A Deep Dive

× How can I help you?