This website is not affiliated with, sponsored by, or approved by SAP AG.

Smartforms: Different font on same field

Development SAPscript/ Smartforms

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Smartforms: Different font on same field

Postby AlainCyr » Wed Nov 18, 2009 7:45 am

Hi,

We are migrating all our remaining SAPScript to Smartforms. The major problem I'm running into is that Character Tags that could be passed dynamically in SAPScript don't work in Smartforms. We are running v4.7.

If I send '123<U>456</>789' as data for a field, with U defined as underline character format, the text will be printed with the tags. In SAPScript, the font was changing to underline for 456.

SmartForms: 123<U>456</>789
SAPScript: 123456789

The fact that placing this tag in a long text and printing this long text with and Include Text object with Smartforms effectively changes the fonts shows me that the functionality still exists in Smartforms but somehow I can't get it to work.

I can't believe that such a basic functionality would have been removed.

Any help will be greatly appreciated. Thanks in advance,

Alain Cyr.
Alain Cyr
System development
L-3 Communications
MAS Canada
AlainCyr
 
Posts: 17
Joined: Tue Jan 28, 2003 3:35 pm
Location: Mirabel, Quebec, Canada

Re: Smartforms: Different font on same field

Postby new2sapfans » Wed Nov 18, 2009 12:24 pm

We too had the same issues. There were other issues regarding INCLUDE command interpretation.

We ended up doing a workaround -
One needs to read the texts into a itab of type TSFTEXT supported by the "dynamic text" include.
AND THEN DISPLAY THE TEXTS VIA THE DYNAMIC TEXT Node in smartform.
This TSFTEXT format will retain the INCLUDE texts and the formatting too.
Remember to insert the <U>, <I> as character formats in your smartstyle.

Code: Select all
FUNCTION Z_EXPLODE_TEXT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(TEXT_ID) TYPE  THEAD-TDID
*"     VALUE(TEXT_LANG) TYPE  THEAD-TDSPRAS
*"     VALUE(TEXT_NAME) TYPE  THEAD-TDNAME
*"     VALUE(TEXT_OBJECT) TYPE  THEAD-TDOBJECT
*"  TABLES
*"      TEXT_TABLE TYPE  TSFTEXT
*"----------------------------------------------------------------------

data : lt_temp   type standard table of tline,
       wa_temp   like line of lt_temp,
       WA_TLINE  LIKE TLINE,
       lv_name(70) type c,
       lv_object(10) type c,
       lv_id(4) type c,
       lv_spras(1) type c,
       token1(100) type c,
       token2(100) type c,
       token3(100) type c,
       token4(100) type c,
       LOCAL_TEXT  TYPE TSFTEXT,
       LOCAL_INCLUDE_TEXT TYPE TSFTEXT.

refresh : lt_temp, LOCAL_TEXT, LOCAL_INCLUDE_TEXT.
clear : wa_tline.

data : lw_stxh type stxh.
select single * from stxh into
lw_stxh where tdobject = TEXT_OBJECT
and     tdname   = TEXT_NAME
and      tdid     = TEXT_ID
and      tdspras  = TEXT_LANG.

if sy-subrc eq 0.
call function 'READ_TEXT'
  exporting
    id                      = TEXT_ID
    language                = TEXT_LANG
    name                    = TEXT_NAME
    object                  = TEXT_OBJECT
  tables
    lines                   = lt_temp
  exceptions
    id                      = 1
    language                = 2
    name                    = 3
    not_found               = 4
    object                  = 5
    reference_check         = 6
    wrong_access_to_archive = 7
    error_message           = 99
    others                  = 8.

if sy-subrc <> 0.
*  message id sy-msgid type sy-msgty number sy-msgno
*  with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
  loop at lt_temp into wa_temp.
    case wa_temp-tdformat.
      when '/:'.
        if wa_temp-tdline cs 'INCLUDE'.
          CLEAR : TOKEN1, TOKEN2, TOKEN3, TOKEN4.
          shift wa_temp-tdline left deleting leading ' '.
          split wa_temp-tdline at 'OBJECT' INTO TOKEN1 TOKEN2.
          REPLACE ALL OCCURRENCES OF 'INCLUDE' IN TOKEN1 WITH SPACE.
          SHIFT TOKEN1 LEFT DELETING LEADING ' '.
          LV_NAME = TOKEN1. "TEXT NAME
          SPLIT TOKEN2 AT 'ID' INTO TOKEN3 TOKEN4.
          SHIFT TOKEN3 LEFT DELETING LEADING ' '.
          CONDENSE TOKEN3.
          LV_OBJECT = TOKEN3.  "TEXT OBJECT
          CLEAR : TOKEN1, TOKEN2, TOKEN3.
          SPLIT TOKEN4 AT 'LANGUAGE' INTO TOKEN1 TOKEN2.
          SHIFT TOKEN1 LEFT DELETING LEADING ' '.
          CONDENSE TOKEN1.
          LV_ID = TOKEN1. "TEXT ID
          CLEAR TOKEN1.
          SPLIT TOKEN2 AT 'PARAGRAPH' INTO TOKEN1 TOKEN3.
          SHIFT TOKEN1 LEFT DELETING LEADING ' '.
          CONDENSE TOKEN1.
          LV_SPRAS = TOKEN1.
          CONDENSE LV_SPRAS.
          IF LV_SPRAS IS INITIAL.
            LV_SPRAS = 'E'.
          ENDIF.

          replace all occurrences of '''' in lv_name with '' .
          TRANSLATE LV_NAME TO UPPER CASE.
          condense : lv_name, lv_object, lv_id.

          CALL FUNCTION 'Z_EXPLODE_TEXT'
            EXPORTING
              TEXT_ID           = lv_id
              TEXT_LANG         = LV_SPRAS
              TEXT_NAME         = lv_name
              TEXT_OBJECT       = lv_object
            TABLES
              TEXT_TABLE        = LOCAL_INCLUDE_TEXT.
          IF SY-SUBRC EQ 0.
            APPEND LINES OF LOCAL_INCLUDE_TEXT TO LOCAL_TEXT.
            REFRESH LOCAL_INCLUDE_TEXT.
          ENDIF.

        endif.
      when others.
        move wa_temp-tdline to wa_tline-tdline.
        move wa_temp-tdformat to  wa_tline-tdformat.
        append wa_tline to LOCAL_TEXT.
    endcase.
  endloop.
endif.
endif.

TEXT_TABLE[] = LOCAL_TEXT[].
REFRESH LOCAL_TEXT.


ENDFUNCTION.
new2sapfans
 
Posts: 71
Joined: Thu Jan 01, 2009 11:01 am

Re: Smartforms: Different font on same field

Postby AlainCyr » Wed Nov 18, 2009 1:39 pm

Thanks for your reply.

I had thought about this but we wanted to avoid this as there will be lots of texts created. Although we might trigger a job to clean these entries.

I would have liked a cleaner way but I'm not sure there is one.

Thanks again,
Alain Cyr.
Alain Cyr
System development
L-3 Communications
MAS Canada
AlainCyr
 
Posts: 17
Joined: Tue Jan 28, 2003 3:35 pm
Location: Mirabel, Quebec, Canada


Return to SAPscript/Smartforms

Who is online

Users browsing this forum: No registered users and 4 guests





This website is not affiliated with, sponsored by, or approved by SAP AG.