Skip to Content
Author's profile photo Former Member

Enhancement for Version Long Text in ME21n/22n/23n

Requirement :

To provide the comments/information with more than 1000 characters  for the New Version triggered.

Procedure :

Step-1 : Check the feasibility to add  a function button on the ALV Tool bar for populating the Text Editor Dialog Box for the requirement.


version-1.PNG

Step-2 :Using Implicit Enhancement Enhanced the ALV Tool bar with a ICON and handle the SY-UCOMM in Version TAB in Purchase Order (Create/Change/Display) Screen.



version-2.PNG

Step-3 : In INCLUDE LMEDCMVCI1 we have Standard Class LCL_DCM_GRID implemented.  The below code is useful to add an ICON in Method TOOL BAR_INIT to provide the feasibility to hold the Text Editor Pop up.


if sytcode = ‘ME22N’ OR SYTCODE = ‘ME23N’ OR SYTCODE = ‘ME29N’.

l_quick = ‘Version Long Text’.

CALL METHOD cl_gui_toolbar=>fill_buttons_data_table

    EXPORTING

      fcode            = ‘&LONG_TEXT’

      icon             = icon_document_revision

*  DISABLED         =

      butn_type        = cntb_btype_button

*   TEXT             =

      quickinfo        = l_quick

*  CHECKED          =

    CHANGING

      data_table       = lt_my_buttons

    EXCEPTIONS

      cntb_btype_error = 1

      OTHERS           = 2.

IF sysubrc = 0.

APPEND LINES OF lt_my_buttons TO ch_buttons.

ENDIF.

ENDIF.


The above code explains that the FUNCTION CODE for the ICON on the ALV Toolbar is defined as ‘LONG_TEXT’.




Step-4 : Using the Function Code “LONG_TEXT” handled the functionality for populating the TEXT EDITOR dialog box , by enhancing the method EXECUTE_BEFORE_TRANSPORT where all the standard function codes are handled.


The executed code is mentioned below.


>> Check if there Version Management is having  any other Version rather than ZERO.


Else through a Information Message that “Initial Version is only exist”.


CASE im_fcode.

      WHEN ‘&LONG’.

*        .list change documents caused by selected revisions

     DATA: lt_models      TYPE mmpur_models,

           ls_models      LIKE LINE OF lt_models,

           ls_erevitem    TYPE erevitem,

           l_rev_item     TYPE REF TO if_revision_item_dcm,

           l_edokp        TYPE erevedokp,

           l_revno_min    TYPE erevitemrevno,

           l_revno_max    TYPE erevitemrevno,

           l_date1        TYPE sydatum,

           l_date2        TYPE sydatum,

           l_time1        TYPE syuzeit,

           l_time2        TYPE syuzeit,

           l_allitems     TYPE xfeld,

           l_header       TYPE erevheader,

           l_num(8)       TYPE n,

           l_num_min(8)   TYPE n,

           num_min(8)   TYPE n,

           l_num_max(8)   TYPE n,

            C TYPE C.

     CHECK NOT my_manager IS INITIAL.

     CALL METHOD get_selection

       IMPORTING

         ex_models = lt_models.

     IF lt_models IS INITIAL.

    MESSAGE I001(Zlng).

    exit.

     ENDIF.

   



b) If we have a New Version rather than ZERO, Then pick the Selected Line Item for which the Long Text should be maintained .



LOOP AT lt_models INTO ls_models.

       mmpur_dynamic_cast l_rev_item ls_modelsmodel.

       CHECK NOT l_rev_item IS INITIAL.

       ls_erevitem = l_rev_item->get_data( ).

*– Portability: REVOK is space or numeric

       l_num = ls_erevitemrevno.

       l_num_min = l_revno_min.

       l_num_max = l_revno_max.

       IF l_num LT l_num_min

       OR l_revno_min IS INITIAL.

         l_revno_min = ls_erevitemrevno.

         l_date1     = ls_erevitemerdat.

         l_time1     = ls_erevitemeruhr.

       ENDIF.

       IF l_num GT l_num_max

       OR l_revno_max IS INITIAL.

         l_revno_max = ls_erevitemrevno.

       ENDIF.

     ENDLOOP.

C) Create a Custom Function module ZMM_LONG_TEXT where we need to handle the functionality with


IMPORTING Parameters :

–> Maximum Version Line Items

–> HEADER ,

–> Current Line Item Selected for the Version Long Text

and

–> System Transaction code


Functionality of the Function Module :


  • Step 1 : Go to SE75 Transaction. Click on change button, Now create Text Object ZVER_LONG.
    Enter the name & Description of Text object. Here in this case, save mode is selected as update because comments data is need to be updated against each development objects table entry In editor ,Editor application is of type Standard Text(TX) and line width is 72 which can be selected as per requirement.
    Style and Form can also be selected from this window, which will decide the display style of text.
    Once the object is being created, double click on the text object.
  • Step 2 : Create Text ids’ .In this scenario, ‘0001’ text Id is created.
  • Step 3 : Once the text ids will be created, front end work is done.
  • READ_TEXT – To retrieve Long Text from Text Objects.
  • SAVE_TEXT – To save Long Text into Text Objects.

FUNCTION zmm_long_text.

*”———————————————————————-

*”*”Local Interface:

*”  IMPORTING

*”     VALUE(L_REVNO_MAX) TYPE  EREVITEM-REVNO

*”     VALUE(L_HEADER) TYPE  EREVHEADER

*”     VALUE(LS_EREVITEM) TYPE  EREVITEM

*”     VALUE(TCODE) TYPE  TCODE

*”  EXPORTING

*”     VALUE(CHECK) TYPE  C

*”———————————————————————-

   DATA : s_revno_max1 TYPE  erevitemrevno,

          s_header1    TYPE  erevheader,

          ss_erevitem1 TYPE  erevitem.

   DATA : t_note    TYPE STANDARD TABLE OF txw_note , ”  WITH HEADER LINE.

          s_note    TYPE txw_note,

          long_text TYPE string,

          v_cnt     TYPE i,

          c         TYPE c.

   l_revno_max1 = l_revno_max.

   l_header1    = l_header.

   ls_erevitem1 = ls_erevitem.

   tcode1        = tcode.

   DATA: e_header  TYPE thead.

   DATAi_tline   TYPE  STANDARD  TABLE  OF tline,

          s_tline   TYPE tline.

   e_headertdobject ‘ZVER_LONG’.

   e_headertdid = ‘0001’ .

   e_headertdspras = sylangu.

   e_headertdlinesize = 72.

   CONCATENATE l_headeredokn ls_erevitemrevno  INTO e_headertdname.

   CALL FUNCTION ‘READ_TEXT’

     EXPORTING

       client                  = symandt

       id                      = ‘0001’

       language                = sylangu

       name                    = e_headertdname

       object                  = ‘ZVER_LONG’

     TABLES

       lines                   = i_tline

     EXCEPTIONS

       id                      = 1

       language                = 2

       name                    = 3

       not_found               = 4

       object                  = 5

       reference_check         = 6

       wrong_access_to_archive = 7

       OTHERS                  = 8.

   IF sysubrc <> 0.

   ENDIF.

   IF i_tline IS INITIAL.

     APPEND INITIAL LINE TO t_note.

   ELSEIF i_tline IS NOT INITIAL.

     LOOP at i_tline INTO s_tline.

       s_noteline = s_tlineTDLINE.

       append s_note to t_note.

       CLEAR s_tline.

       ENDLOOP.

   ENDIF.

   IF tcode = ‘ME22N’.

     IF ls_erevitemrevok IS INITIAL.

       c = ‘X’.

     ELSE.

       c = ‘ ‘.

     ENDIF.

   ELSEIF tcode = ‘ME23N’.

     c = ‘ ‘.

   ENDIF.

   CALL FUNCTION ‘TXW_TEXTNOTE_EDIT’

     EXPORTING

       edit_mode = c

     TABLES

       t_txwnote = t_note.

   IF syucomm = ‘CONT’.

     REFRESH i_tline.

*    APPEND LINES OF t_note TO i_tline.

         LOOP at t_note INTO s_note.

        s_tlinetdline = s_noteLINE .

       append s_tline to i_tline.

       CLEAR s_note.

       ENDLOOP.

     CALL FUNCTION ‘SAVE_TEXT’

       EXPORTING

         client          = symandt

         header          = e_header

         savemode_direct = ‘X’

       TABLES

         lines           = i_tline

       EXCEPTIONS

         id              = 1

         language        = 2

         name            = 3

         object          = 4

         OTHERS          = 5.

     IF sysubrc = 0.

       check = ‘X’.

* Implement suitable error handling here

     ENDIF.

   ELSE.

     EXIT .

ENDIF.

ENDFUNCTION.

D) Using the above Function module we can able to maintain the Version Long Text which can be more than 1000 characters.

Detail Enhanced Code:

CASE im_fcode.

      WHEN ‘&LONG’.

*        .list change documents caused by selected revisions

     DATA: lt_models      TYPE mmpur_models,

           ls_models      LIKE LINE OF lt_models,

           ls_erevitem    TYPE erevitem,

           l_rev_item     TYPE REF TO if_revision_item_dcm,

           l_edokp        TYPE erevedokp,

           l_revno_min    TYPE erevitemrevno,

           l_revno_max    TYPE erevitemrevno,

           l_date1        TYPE sydatum,

           l_date2        TYPE sydatum,

           l_time1        TYPE syuzeit,

           l_time2        TYPE syuzeit,

           l_allitems     TYPE xfeld,

           l_header       TYPE erevheader,

           l_num(8)       TYPE n,

           l_num_min(8)   TYPE n,

           num_min(8)   TYPE n,

           l_num_max(8)   TYPE n,

            C TYPE C.

     CHECK NOT my_manager IS INITIAL.

     CALL METHOD get_selection

       IMPORTING

         ex_models = lt_models.

     IF lt_models IS INITIAL.

    MESSAGE I001(Zlng).

    exit.

     ENDIF.

     LOOP AT lt_models INTO ls_models.

       mmpur_dynamic_cast l_rev_item ls_modelsmodel.

       CHECK NOT l_rev_item IS INITIAL.

       ls_erevitem = l_rev_item->get_data( ).

*– Portability: REVOK is space or numeric

       l_num = ls_erevitemrevno.

       l_num_min = l_revno_min.

       l_num_max = l_revno_max.

       IF l_num LT l_num_min

       OR l_revno_min IS INITIAL.

         l_revno_min = ls_erevitemrevno.

         l_date1     = ls_erevitemerdat.

         l_time1     = ls_erevitemeruhr.

       ENDIF.

       IF l_num GT l_num_max

       OR l_revno_max IS INITIAL.

         l_revno_max = ls_erevitemrevno.

       ENDIF.

     ENDLOOP.

if sysubrc = 0 .

     l_header = my_manager->get_data( ).

endif.

if L_REVNO_MAX <> ‘00000000’.

CALL FUNCTION ‘ZMM_LONG_TEXT’

   EXPORTING

     L_REVNO_MAX       L_REVNO_MAX

     L_HEADER          = l_header

     LS_EREVITEM       = LS_EREVITEM

     TCODE             = SYTCODE

     IMPORTING

       CHECK           = C.

ELSE.

   MESSAGE i000(zlng) .

   EXIT.

ENDIF.

IF  C = ‘X’.

MESSAGE s002(zlng) WITH ls_erevitemrevno.

IF ls_erevitemZZTEXT1 IS INITIAL.

  ls_erevitemZZTEXT1 = ‘X’.

  ELSE.

    CLEAR ls_erevitemZZTEXT1.

    ENDIF.

CALL METHOD l_rev_item->set_data( ls_erevitem ).

CALL METHOD notify_data_changed( l_rev_item ).

ENDIF.

ENDCASE.

  

Test Case :

>> 1) Open The Purchase Order (ME21n/ME22n/ME23n) & navigate to Version Tab as mention below

version-3.PNG

>> 2) Select the Line Item for which the Long Text should be maintained and

         Click on the Long Text ICON as shown below

version-2.PNG

>>3) Now u can able to Create/Change/Display the Version Long Text maintained

version-4.PNG

Thanks & Regards,

S.Rajendranath

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.