Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8635

Re: Create Smartform Text Module Using ABAP

$
0
0

Hi,

 

There is the language to be passed to the store( ) method as well - if you don't pass it, it seems to be saved in sy-langu... I was able to create Texts in EN and DE when I took over new_master_language to header-masterlang and then passed it on to store( ). I changed my previous post to reflect the code changes.

 

The languages other than masterlang are probably easiest created using translation functionality in Function group STXBT, namely SSFTR_SET_TEXT. There the guys have "cut the OO crap" and done it directly in stxftxt table... That FM, however, does not let to set the caption...

 

There probably are good reasons why SAP programmed this stuff the way they did, and I may expect "gratification" too soon when starting to work with code I don't know well... but the more I look at it the more I find SSF code irritating Couple of years ago I was trying to understand if there is easy way to program some kind of search for smartform. Then I pretty soon decided that it's not worth the time investment and started downloading to xml for searching...

 

cheers

Janis

 

Message was edited by: Jānis B: ok, I can't change the previous post anymore

 

  METHOD create_from_itf_text.

 

    DATA: lo_ssf_text_module TYPE REF TO zcl_ssf_text_module .

    DATA: lo_text_item TYPE REF TO cl_ssf_fb_text_item .

    DATA: ls_varheader TYPE ssfvarhdr .

    DATA: l_devclass TYPE devclass .

    DATA: l_master_language TYPE sylangu .

    DATA: l_korrnum TYPE trkorr .

    DATA: l_modif_language TYPE sylangu .

 

    CREATE OBJECT lo_ssf_text_module .

 

* grrr!

    CREATE OBJECT lo_ssf_text_module->mo_form .

 

* try to lock first

    lo_ssf_text_module->mo_form->enqueue(

           EXPORTING  suppress_corr_check        = space

                      language_upd_exit          = space

                      master_language            = i_langu

                      mode                       = 'INSERT'

                      formname                   = i_formname

           IMPORTING  devclass                   = l_devclass

                      new_master_language        = l_master_language

                      korrnum                    = l_korrnum

                      modification_language      = l_modif_language

    ).

 

* init boilerplate

    PERFORM create_default_text

      IN PROGRAM saplstxb

        CHANGING lo_ssf_text_module->mo_form.

 

* Take over attributes

    lo_ssf_text_module->mo_form->header-formname = i_formname .

    lo_ssf_text_module->mo_form->header-caption = i_caption .

    lo_ssf_text_module->mo_form->header-devclass = i_devclass .

    lo_ssf_text_module->mo_form->header-masterlang = l_master_language .

 

* get to the Text object

    READ TABLE lo_ssf_text_module->mo_form->varheader

      INTO ls_varheader INDEX 1 .

    lo_text_item ?= ls_varheader-pagetree->obj .

 

* Take over text

    lo_text_item->text[] = it_tsftext[] .

    MODIFY lo_ssf_text_module->mo_form->varheader

       FROM ls_varheader INDEX 1 .

 

* Return instance

    ro_ssf_text_module = lo_ssf_text_module .

 

  ENDMETHOD.                    "create_from_itf_text

 

  METHOD save.

 

    DATA: lx_ssf_fb TYPE REF TO cx_ssf_fb .

 

    TRY .

        me->mo_form->store(

          EXPORTING

            im_active   = 'X'   "Must always be active

            im_formname = me->mo_form->header-formname

            im_language = me->mo_form->header-masterlang

        ).

      CATCH cx_ssf_fb INTO lx_ssf_fb .

        me->unlock( ) .

        RAISE EXCEPTION lx_ssf_fb .

    ENDTRY .

 

  ENDMETHOD.                    "save


Viewing all articles
Browse latest Browse all 8635

Trending Articles