ABAP Overcome Limitation of Long Text Links Handling using Custom Class

By | July 13, 2015 | Utilities | 11,344 | 0

Lets talk about the Links in the Message Long text. This is also applicable to any documentation as well. There are few limitations, I will show you how to overcome them.

Links in Standard SAP

Using the SAP you can provide, links to the transaction code or reports or documentation to the Data elements in the Long Texts. This not limited to only Message Long Text. This helps users to directly navigate from the long text to the different subsequent activity.

For demo purpose, I will take Message long text to show how you can add the link to it.

To add the link to Message Long text in SE91:

  1. Navigate to message long text.
  2. Select Insert > Link
  3. Select Transaction Code from the Popup
  4. Enter the Transaction as MM03 and add the text to display
ABAP_Long_Text_Link_2

This would generate the text like this:

<DS:TRAN.MM03>View Material Master</>

To test, raise the message and press the ? to see the long text. In the long text, click on the View Material Master to call MM03.

Passing the Data

Now, this is great. But it would be even more beautiful if we can send the material number. Standard SAP allows you to pass the parameters to the link. There are different techniques for different document class.

For Transaction Code

For Transaction code, you can send the additional details using parenthesis ( ). The syntax would be:

<DS:TRAN.MM03(MAT.&SYST-MSGV1&)>Material Master</>

Here, MAT is the material parameter ID. The values is being passed in the message variable &SYST-MSGV1& — The message is (Material &1 has low stock.).

To call Reports with data

For reports, you would need to pass the variant name along with the report name. Std SAP calls the report with the variant.

<DS:REPO.RM07DOCS.VARI1>Material Documents</>

Here, RM07DOCS is the report and VARI1 is the variant, separated by a dot

Activation Error

You would get error while activation, but just ignore that and continue activation.

ABAP_Long_Text_Link_Activate_Error

Limitations

Things are looking interesting so far, but there are few limitations:

  • Only 20 characters are passed to the logic, for TRAN document class. This 20 characters include the Transaction name, Parameter ID, Message variable
  • Calling the Report may not be feasible with variant all the time as there would be different values for the variant. This would need to be done by creating a temporary variant before message call, and delete it afterwords.

Overcome the limitations – Custom class to handle the Links

Let me show you, how you can overcome these limitations.

The idea is to use the custom document class in the documentation and have a custom event handler class to handle the link click. Sounds good, huh?

Follow these steps to create necessary setup:

  • Inherit a custom class say ZCL_EPSS_SAPEVENT_HANDLE from CL_EPSS_SAPEVENT
  • Redefine the method RESOLVE_LINK
  • Add a case statement DOC_LINK+3(4). When Custom Document Type (e.g. ZTRA) call custom logic, When others call SUPER->RESOLVE_LINK( )
  • In documentation – use the Custom Document Type ZTRA instead of TRAN
  • Update the EPPS methods table to use this custom class ZCL_EPSS_SAPEVENT_HANDLE – Use SM30 for table EPSSA2 to update the new class

Your class should be look like this:

ABAP_Long_Text_Link_Custom_Class

Customizing to use the Custom class

ABAP_Long_Text_Link_Custom_Class_Handler

Lets change the way we pass the data from the message text to the event callback.

<DS:ZTRA.MMBE.MAT=&SYST-MSGV1&.WRK=&SYST-MSGV2&.CHG=&SYST-MSGV3&>Call MMBE</>

This would be easy to find out the necessary parameters and values using this type of parameter passing. Split at dot and than split at equal sign.

Class ZCL_EPSS_SAPEVENT_HANDLE

Method RESOLVE_LINK redefinition. Here we are gonna handle the custom Document Type, and let the SUPER->RESOLVE_LINK (Method RESOLVE_LINK in class CL_EPSS_SAPEVENT)

 
METHOD resolve_link.
*
  me->doc_link         = doc_link.
  me->epss_html_viewer = epss_html_viewer.
  me->help_info        = help_info.
 
  CASE  doc_link+3(4).
    WHEN 'ZTRA'.
      me->ztransaction( ).
 
    WHEN 'ZREP'.
      me->zsubmit_report( ).
 
    when 'ZURL'.
      me->ZURL( ).
 
    WHEN OTHERS.
      super->resolve_link(
        doc_link = doc_link
        epss_html_viewer = epss_html_viewer
        help_info = help_info
      ).
  ENDCASE.
 
ENDMETHOD.
 

URL Callback

To call the URL when we have ZURL document type:

 
METHOD zurl.
  "<DS:ZURL.http://www.zevolving.com>Call Website</>
  DATA: lv_url TYPE bxmnodes-url.
 
  lv_url = doc_link+8.
 
  CALL FUNCTION 'PRGN_START_EXECUTE_MODULE'
    EXPORTING
      url_type = 'URL'
      url      = lv_url.
 
ENDMETHOD.
 

Add this in message long text:

 
<DS:ZURL.http://www.zevolving.com>Call Website</>
 

And simply call the message.

To test, you would need to see the long text and press the click.

Report Program Callback

Method ZREPORT_SUBMIT to handle ZREP. To be able to handle the data properly, a static variable is used in the class. This would be populated before calling the message. If message long text report callback is called, the data would be passed from static to the report SUBMIT.

 
METHOD zsubmit_report.
 
  " DOC_LINK has the link info
  "<DS:ZREP.RMMMBESTN>Report MMBE</>
 
  TYPES: tt_parts   TYPE STANDARD TABLE OF char50.
  DATA: lv_part   TYPE char50.
  DATA: lt_parts  TYPE tt_parts.
  DATA: lt_params TYPE tt_parts.
 
  "
  DATA: lv_prog  TYPE sy-cprog.
  DATA: lv_name  TYPE char30.
  DATA: lv_value TYPE char50.
 
  SPLIT doc_link+8  "Ignore DS:ZREP.
    AT '.'
    INTO TABLE lt_parts.
 
* 1st = Report
  READ TABLE lt_parts INTO lv_part INDEX 1.
  IF sy-subrc EQ 0.
    lv_prog = lv_part.
  ENDIF.
  IF lv_prog IS INITIAL.
    MESSAGE 'Report is not supplied' TYPE 'I'.
    EXIT.
  ENDIF.
 
  SUBMIT (lv_prog)
    VIA SELECTION-SCREEN
    AND RETURN
    WITH SELECTION-TABLE t_rspar.
 
  CLEAR: zcl_test_np_epss_sapevent=>t_rspar.
 
ENDMETHOD.
 

Add this into the message long text:

 
<DS:ZREP.RMMMBESTN>Report MMBE</>
 

And call the message:

 
DATA: rspar_line LIKE LINE OF ZCL_TEST_NP_EPSS_SAPEVENT=>t_rspar.
 
 
rspar_line-selname = 'MS_MATNR'.
rspar_line-kind    = 'S'.
rspar_line-sign    = 'I'.
rspar_line-option  = 'EQ'.
rspar_line-low     = 'TEST_NP'.
APPEND rspar_line TO ZCL_TEST_NP_EPSS_SAPEVENT=>t_rspar.
 
rspar_line-selname = 'MS_WERKS'.
rspar_line-low     = '1100'.
APPEND rspar_line TO ZCL_TEST_NP_EPSS_SAPEVENT=>t_rspar.
 
 
MESSAGE I002(Z_TESTMESSAGE) with 'TEST_NP' '1100'.
 

Transaction Callback

Create Method ZTRANSACTION to handle the Custom Transaction event ZTRA:

 
METHOD ztransaction.
 
  " DOC_LINK has the link info
  "<DS:ZTRA.MMBE.MAT=&SYST-MSGV1&.WRK=&SYST-MSGV2&.CHG=&SYST-MSGV3&>Call MMBE</>
 
  TYPES: tt_parts   TYPE STANDARD TABLE OF char50.
  DATA: lv_part   TYPE char50.
  DATA: lt_parts  TYPE tt_parts.
  DATA: lt_params TYPE tt_parts.
 
  "
  DATA: lv_tcode TYPE sy-tcode.
  DATA: lv_param TYPE memoryid.
  DATA: lv_value TYPE char50.
 
  SPLIT doc_link+8  "Ignore DS:ZTRA.
    AT '.'
    INTO TABLE lt_parts.
 
* 1st = TCODE
  READ TABLE lt_parts INTO lv_part INDEX 1.
  IF sy-subrc EQ 0.
    lv_tcode = lv_part.
  ENDIF.
  IF lv_tcode IS INITIAL.
    MESSAGE 'T-Code is not supplied' TYPE 'I'.
  ENDIF.
 
*
  LOOP AT lt_parts INTO lv_part FROM 2.
    CLEAR: lv_param, lv_value.
 
    SPLIT lv_part
      AT '='
      INTO lv_param
           lv_value.
 
    IF  lv_param IS NOT INITIAL.
      SET PARAMETER ID lv_param FIELD lv_value.
    ENDIF.
  ENDLOOP.
 
  CALL TRANSACTION lv_tcode.
 
ENDMETHOD.
 

To Use it, add this into message long text:

<DS:ZTRA.MMBE.MAT=&SYST-MSGV1&.WRK=&SYST-MSGV2&.CHA=&SYST-MSGV3&>MMBE</>

Call the message:

 
MESSAGE I002(Z_TESTMESSAGE) with 'TEST_NP' '1100'.
 

Notes:

  • Create different Custom document type – for CALL TRANSACTION, CALL TRANSACTION and SKIP INITIAL SCREEN.
  • Pass data using the Static variables or Function Modules in the same Function group

Solution was originally discussed at SCN – DS:REPN Parameters

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.