SAP ABAP, ABAP Development

How to Use Dynamic SO10 Text in BRF+ Adobe Form Output

In this post, I would like to share with you, how to use dynamic SO10 text elements on standard Adobe form that you maintain with SFP tcode and also show you, how to achieve same thing with BRF+ Adobe form outputs those need to be maintained in Adobe Live Cycle application.

SFP PART

For non BRF+ cases, If you want to use SO10 text elements with their styles in Adobe form, you can go to SFP transaction, create a form and add TEXT element to context, bind that text element to a text object on layout. That is it, it will work nicely.

You can drag and drop from context to layout. It will create necessary element on layout with bindings.

First lets see, how we can do it with SFP tcode.

To Add Text to Context
Non BRF+ Form
Layout Object properties for TEXT element

And sample code to read to text for the case above

METHOD fill_doc_ship_type_txt.
    DATA: exref TYPE REF TO cx_root.
    TRY.
        CLEAR docstc-ship_type_text_name.
        IF docstc-vstel IS NOT INITIAL AND docstc-vsart IS NOT INITIAL.
          
          "Some logic to determine name
          docstc-ship_type_text_name = 'ZDLVY_XYZ' && docstc-vstel && '_' && docstc-vsart.
          CONDENSE docstc-ship_type_text_name NO-GAPS.

          IF langu IS INITIAL.
            langu = 'E'.
          ENDIF.

          docstc-ship_type_text_langu = langu.

          CALL FUNCTION 'READ_TEXT'
            EXPORTING
              id                      = 'ST'
              language                = docstc-ship_type_text_langu
              name                    = docstc-ship_type_text_name
              object                  = 'TEXT'
            TABLES
              lines                   = docstc-ship_type_text "Contains text lines, type TSFTEXT
            EXCEPTIONS
              id                      = 1
              language                = 2
              name                    = 3
              not_found               = 4
              object                  = 5
              reference_check         = 6
              wrong_access_to_archive = 7
              OTHERS                  = 8.
          IF sy-subrc <> 0.

            IF langu NE 'E'.
              result = fill_doc_ship_type_txt( langu = 'E' ).
            ELSE.
              result-status = c_stat_warning.
              IF NOT sy-msgid IS INITIAL.
                MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                      INTO result-status_text.
              ENDIF.
            ENDIF.

          ELSE.
            result-status = c_stat_success.
          ENDIF.

        ELSE.
          result-status = c_stat_error.
        ENDIF.

      CATCH cx_root INTO exref.
        result-status = c_stat_error.
        result-status_text = exref->get_text( ).
    ENDTRY.
  ENDMETHOD.

That is it for SFP form. With those steps above, you can use TEXT element with dynamic text objects in non BRF+ forms.

BRF+ PART

But, if you want to have same functionality with BRF+, you need to download your form from fiori app “Maintain Form Templates” and then edit form in Adobe Live Cycle Designer. Once you complete editing you need to upload them back. The problem is, Adobe Live Cycle Designer does not have context to add TEXT object. It does not know about SAP SO10.

There is a solution! You can pass string that contains html tags such as and run Javascript code events to interpret the string as html.

Now lets see how to do that.

First we need to add tags to our SO10 text.

in Word Editor

In XYZ_get_entityset method we will read our text and concatenate it according SO10.

method xyz_get_entitsey.
............

CALL FUNCTION 'READ_TEXT' 
      EXPORTING 
        id                      = 'ST' 
        language                = 'E' 
        name                    = name 
        object                  = 'TEXT' 
      TABLES 
        lines                   = texts-tdlines 
      EXCEPTIONS 
        id                      = 1 
        language                = 2 
        name                    = 3 
        not_found               = 4 
        object                  = 5 
        reference_check         = 6 
        wrong_access_to_archive = 7 
        OTHERS                  = 8. 
 
    IF sy-subrc IS INITIAL. 
 
      CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT' 
        EXPORTING 
          language     = 'E' 
          lf           = abap_true 
        IMPORTING 
          stream_lines = texts-strlines 
        TABLES 
          itf_text     = texts-tdlines. 

      "Add Lines to entityset table      
      DATA: newline TYPE LINE OF zcl_zfdp_ef_purchase_o_mpc=>tt_pofixtext. 
      LOOP AT texts-strlines ASSIGNING FIELD-SYMBOL(<wa>). 
        CLEAR newline. 
        newline-seqno = sy-tabix. 
        newline-tdline = <wa>. 
 
        "Some sort of logic to open close tags for each line, in case if user forgets to add                
        "Javascript event will work for each line,therefore tags needs to exists for each line
        IF newline-tdline CP '*<b>*' AND NOT newline-tdline CP '*</b>*'. 
          newline-tdline = newline-tdline && '</b>'. 
        ELSEIF newline-tdline CP '*</b>*' AND NOT newline-tdline CP '*<b>*'. 
          newline-tdline = '<b>' && newline-tdline. 
        ENDIF. 
 
        IF newline-tdline CP '*<u>*' AND NOT newline-tdline CP '*</u>*'. 
          newline-tdline = newline-tdline && '</b>'. 
        ELSEIF newline-tdline CP '*</u>*' AND NOT newline-tdline CP '*<u>*'. 
          newline-tdline = '<u>' && newline-tdline. 
        ENDIF. 
 
        IF newline-tdline CP '*<i>*' AND NOT newline-tdline CP '*</i>*'. 
          newline-tdline = newline-tdline && '</b>'. 
        ELSEIF newline-tdline CP '*</i>*' AND NOT newline-tdline CP '*<i>*'. 
          newline-tdline = '<i>' && newline-tdline. 
        ENDIF. 
 
        APPEND newline TO et_entityset. 
      ENDLOOP. 
    ENDIF. 
..........
endmethod.

Add a table to list rows, as you would do for any table view.

shows Tdline element of table

And just add a javascript initialize event with following code.

// Form.FixText.xyz.Tdline::initialize - (JavaScript, client)
if(this.rawValue != null)
{
	var envelope = "<?xml version='1.0' encoding='UTF-8'?>" +
	  "<exData contentType='text/html' xmlns='http://www.xfa.org/schema/xfa-template/2.8/'" +
	  "><body xmlns='http://www.w3.org/1999/xhtml' xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/' " +
	  "xfa:APIVersion='Acroform:2.7.0.0' xfa:spec='2.1'>" +
	  "<p>"+ this.rawValue +"</p></body></exData>";
	
	this.value.exData.loadXML(envelope,1,1);
}

And if you print, you will see;

PDF Output

There were blog posts and answers to give clues on solving BRF+ and SO10 case. But there was not a complete answer.