Posts

Showing posts from November, 2025

Workflow – Reading Container Values Using FM and Class

Hello Everyone!👋 Reading Workflow Container Values Using FM and Class If you’ve worked with workflows, you’ve likely encountered situations where you need to access container values within your program. Most of the time, we use the function module SAP_WAPI_READ_CONTAINER for this. However, there’s an alternative approach you can also retrieve container values using the class CL_SWF_RUN_WORKITEM_CONTEXT . CLASS lcl_workflow_container DEFINITION. PUBLIC SECTION. METHODS: get_value_using_fm IMPORTING iv_wi_id TYPE sww_wiid iv_element_name TYPE swfdname EXPORTING ev_value TYPE any. METHODS: get_value_using_method IMPORTING iv_wi_id TYPE sww_wiid iv_element_name TYPE swfdname EXPORTING ev_value TYPE any RAISING cx_swf_cnt_container. ENDCLASS. CLASS lcl_workflow_container IMPLEMENTATION. METHOD get_value_using_fm. TYPES: tt_swr_cont TYPE TABLE O...

Flexible Workflow - Collaborative Attachment and Comment Handling

Image
Hello Everyone!👋 Flexible Workflow - Collaborative Attachment and Comment Handling. This feature allows to share attachments and comments between main and review flow items.This feature allows to share attachments and comments between main and review flow items. So, for instance, if an approver adds a comment, the reviewer will immediately see this comment. Any attachment or comment added to any work item (in the main flow or review flow) will instantly be visible in My Inbox for any work item belonging to the same workflow instance.

Workflow - Fetch Approver Comments

Image
Hello Everyone!👋 Fetch Approver Comments from Workflow If you’ve worked with My Inbox, you’ve probably seen that when rejecting a work item, users must enter a comment so the requester understands what needs to be fixed before resubmitting. But how do we retrieve those comments? You can use the following CDS view or class to fetch the decision note (approver comments) from the work item: CDS: I_WorkflowTaskResultComment Class: CL_WAPI_DECISION_COMMENT_QUERY Note:If this CDS view exists in your system and you want to fetch comments from older or completed work items, you can run the report RSWW_SET_WORKITEM_COMMENTS (if needed).

ABAP SQL - COALESCE Function

Image
Hello Everyone!👋 SQL COALESCE Function in ABAP The COALESCE function is extremely useful when working with optional or missing data. It accepts a list of at least two (and up to 255) arguments — COALESCE(arg1, arg2, …, argn) and returns the first non-null value in the list. If all values are null, it returns the last argument. Here is a small example, We have three tables: 𝗹𝘁_𝘀𝗮𝗹𝗲𝘀𝗼𝗿𝗱𝗲𝗿𝘀 : Contains sales orders with net values and customer IDs. DATA(lt_salesorders) = VALUE tt_salesorder( ( salesorder = '1' netvalue = '100.00' customer = 'CUST_1' ) ( salesorder = '2' netvalue = '100.00' customer = 'CUST_2' ) ( salesorder = '3' netvalue = '100.00' customer = 'CUST_3' ) ). 𝗹𝘁_𝗰𝘂𝘀𝘁𝗼𝗺𝗲𝗿_𝗼𝗻𝗲 and 𝗹𝘁_𝗰𝘂𝘀𝘁𝗼𝗺𝗲𝗿_𝘁𝘄𝗼 : Two datasets with customer names and address IDs. DATA(lt_customer_one) = VALUE tt_customer( ( customer = 'CUST_1' customername = 'Cus...

ABAP - STEP Keyword

Hello Everyone!👋 STEP Keyword in ABAP The STEP keyword in ABAP simplifies working with loops when you want to skip odd or even indices. Previously, this was achieved using sy-tabix , but with STEP , you can directly control both the step size and the loop's direction, making the process more straightforward and efficient. Here is a small example: TYPES: tt_numbers TYPE TABLE OF int8 WITH EMPTY KEY. DATA(lt_numbers) = VALUE tt_numbers( FOR i = 1 THEN i + 1 WHILE i Forward LOOP AT lt_numbers INTO DATA(forward_num) STEP 2. WRITE:/ forward_num. ENDLOOP. DATA(lt_step_forward) = VALUE tt_numbers( FOR num in lt_numbers STEP 2 ( num ) ). "Output -> 1,3,5,7,9 "Step with Negative Number -> Backward LOOP at lt_numbers INTO DATA(backword_num) STEP -2. WRITE:/ backword_num. ENDLOOP. DATA(lt_step_backward) = VALUE tt_numbers( FOR num in lt_numbers STEP -2 ( num ) ). "Output -> 10,8,6,4,2 "Step with From and To LOOP AT lt_...

ABAP String Template - Embedded Expression Format Options

👋 Hello Everyone! ABAP String Templates – Embedded expressions Here are some useful string templates with embedded expression format options in ABAP that can be helpful in various scenarios "String Templates "ALPHA(IN/OUT) DATA(lv_vbeln) = CONV vbeln( '1' ). lv_vbeln = |{ lv_vbeln ALPHA = IN }|. "-> 0000000001 lv_vbeln = |{ lv_vbeln ALPHA = OUT }|. "-> 1 "WIDTH DATA(lv_vbeln_with_extra_zeros) = |{ lv_vbeln ALPHA = IN WIDTH = 15 }|. "->000000000000001 "CURRENCY DATA(lv_amount) = 123456. DATA(lv_inr) = |{ lv_amount CURRENCY = 'INR' }|. "1234.56 DATA(lv_omr) = |{ lv_amount CURRENCY = 'OMR' }|. "123.456 "NUMBER DATA(lv_number) = 12345678. DATA(lv_user_specific) = |{ lv_number NUMBER = USER }|. "12.345.678 SET COUNTRY 'US'. DATA(lv_env) = |{ lv_number NUMBER = ENVIRONMENT }|. "12,345,678 "DATE -> Same we have for TIME,TIMESTAMP DATA(lv_date) ...

ABAP - RETURN Statement Now Supports Returning Values

👋 Hello Everyone! ABAP RETURN Statement Enhancement (ABAP 7.58) In ABAP, the 𝗥𝗘𝗧𝗨𝗥𝗡 statement has been used to exit a procedure, such as a method or a function module. Unlike many other programming languages where 𝗿𝗲𝘁𝘂𝗿𝗻 is used to pass a value back from a function, earlier versions of ABAP did not support this functionality. However, starting with ABAP 7.58, the 𝗥𝗘𝗧𝗨𝗥𝗡 statement can now be used to return a value directly from a method. Note: This applies only to methods that have a returning parameter. CLASS lcl_demo DEFINITION. PUBLIC SECTION. CLASS-METHODS: return RETURNING VALUE(rv_value) TYPE text100, return_with_value RETURNING VALUE(rv_value) TYPE text100, return_structure RETURNING VALUE(rs_vbak) TYPE vbak, return_table RETURNING VALUE(rt_table) TYPE tt_vbak. ENDCLASS. CLASS lcl_demo IMPLEMENTATION. METHOD return. rv_value = 'Something'. RETURN. ENDMETHOD. METHOD retur...

CDS - Enable Search on Child Entity Fields in List Report

👋 Hello Everyone! Enable Search on Child Entity Fields in List Report If you want to make fields from an child entity available in the global search(List Report), Just follow these steps to achieve. 1️⃣ In your Root Entity, mark the exposed child entity with the annotation: @Search.defaultSearchElement: true _Booking; 2️⃣ In the child entity, specify the fields you want to be searchable: @Search.defaultSearchElement: true CarrierName; 🎥 Demo: Search on Child Entity Field (OData V4) 🔍 You can also enhance the search experience by enabling fuzzy search settings. Once this is done, the relevant fields will be included in the global search.

CDS - Filter List Reports by Child Entity Fields

👋 Hello Everyone! Filter List Reports by Child Entity Fields Have you ever wanted to filter a list report based on a field from a child entity ? For example, filtering travel records by the AirlineID from the associated _Booking entity? You can achieve this by adding the following annotation to the root CDS view metadata extension (e.g., Travel ): @UI.selectionField: [{ element: '_Booking.AirlineID', position: 50 }] _Booking; 🎥 Demo: Filtering by Child Entity Field (OData V4) I tested this in the BTP ABAP Environment , and it works perfectly — but only with OData V4 .

CDS - Highlight Line Items and Columns Based on Criticality

Image
👋 Hello Everyone! Highlight line items and fields based on Criticality If you want to visually differentiate rows or columns based on certain values (like status), you can achieve this using the CriticalityCode . This enhances the UI/UX. In this example, I’ve highlighted both line items and columns based on the status. Step 1: Derive the CriticalityCode Based on OverallStatus define root view entity ZR_ROOT_ENTITY { ... OverallStatus, case $projection.OverallStatus when 'A' then 3 // 3 - Green when 'X' then 1 // 1 - Red when 'O' then 2 // 2 - Yellow else 0 // 0 - Neutral end as CriticalityCode } Step 2: Expose CriticalityCode in the Projection View define root view entity ZC_ROOT_ENTITY provider contract transactional_query as projection on ZR_ROOT_ENTITY { ... OverallStatus, CriticalityCode }...

CDS - Dynamic Semantic Navigation

👋 Hello Everyone! Dynamic Semantic Navigation in CDS I recently encountered a scenario where I needed to navigate to different apps based on the type of a technical object — Functional Location or Equipment . Since CDS doesn’t support dynamic semantic object/action assignment, I implemented a workaround by grouping two fields into a single column, each configured with its own semantic object and action. Based on the object type, I conditionally hide one of the fields. For example, if the object type is Equipment , the column shows a link that navigates to the Equipment app. If it’s Functional Location , it displays a link to the Functional Location app. Below is the CDS logic that enables this dynamic navigation: @AccessControl.authorizationCheck: #NOT_REQUIRED define view entity ZR_TechnicalObject as select from I_TechnicalObject { key TechnicalObject, key TechObjIsEquiporFuncnlloc,...

CDS - Use Conversion Exits Directly at Element Level

Image
👋 Hello Everyone! We often face scenarios where a user enters an ID without leading zeros, but the system needs to store it with leading zeros while still displaying it without them. Usually, this is handled using a domain with a conversion exit (like VBELN ), assigning that domain to the data element, and then to the field. But sometimes we work with existing data elements or predefined types (like ABAP.CHAR(10) ) that don’t have conversion exits. In those cases, we usually add zeros manually using RAP determinations and trim the leading zeros in CDS. Now it’s much simpler! With the annotation: @AbapCatalog.typeSpec.conversionExit: 'ALPHA' In the example below, consider a table field for a 10-digit mobile number (predefined type CHAR(10) ). With this annotation, leading zeros will be automatically added during processing. ...