Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

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.


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.



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 sy-tcode = 'ME22N' OR SY-TCODE = 'ME23N' OR SY-TCODE = '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 sy-subrc = 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 erev-edokp,


           l_revno_min    TYPE erevitem-revno,


           l_revno_max    TYPE erevitem-revno,


           l_date1        TYPE sy-datum,


           l_date2        TYPE sy-datum,


           l_time1        TYPE sy-uzeit,


           l_time2        TYPE sy-uzeit,


           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_models-model.


       CHECK NOT l_rev_item IS INITIAL.


       ls_erevitem = l_rev_item->get_data( ).


*-- Portability: REVOK is space or numeric


       l_num = ls_erevitem-revno.


       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_erevitem-revno.


         l_date1     = ls_erevitem-erdat.


         l_time1     = ls_erevitem-eruhr.


       ENDIF.


       IF l_num GT l_num_max


       OR l_revno_max IS INITIAL.


         l_revno_max = ls_erevitem-revno.


       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  erevitem-revno,


          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_header-tdobject 'ZVER_LONG'.


   e_header-tdid = '0001' .


   e_header-tdspras = sy-langu.


   e_header-tdlinesize = 72.


   CONCATENATE l_header-edokn ls_erevitem-revno  INTO e_header-tdname.



   CALL FUNCTION 'READ_TEXT'


     EXPORTING


       client                  = sy-mandt


       id                      = '0001'


       language                = sy-langu


       name                    = e_header-tdname


       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 sy-subrc <> 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_note-line = s_tline-TDLINE.


       append s_note to t_note.


       CLEAR s_tline.


       ENDLOOP.


   ENDIF.





   IF tcode = 'ME22N'.


     IF ls_erevitem-revok 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 sy-ucomm = 'CONT'.


     REFRESH i_tline.


*    APPEND LINES OF t_note TO i_tline.


         LOOP at t_note INTO s_note.


        s_tline-tdline = s_note-LINE .


       append s_tline to i_tline.


       CLEAR s_note.


       ENDLOOP.



     CALL FUNCTION 'SAVE_TEXT'


       EXPORTING


         client          = sy-mandt


         header          = e_header


         savemode_direct = 'X'


       TABLES


         lines           = i_tline


       EXCEPTIONS


         id              = 1


         language        = 2


         name            = 3


         object          = 4


         OTHERS          = 5.


     IF sy-subrc = 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 erev-edokp,


           l_revno_min    TYPE erevitem-revno,


           l_revno_max    TYPE erevitem-revno,


           l_date1        TYPE sy-datum,


           l_date2        TYPE sy-datum,


           l_time1        TYPE sy-uzeit,


           l_time2        TYPE sy-uzeit,


           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_models-model.


       CHECK NOT l_rev_item IS INITIAL.


       ls_erevitem = l_rev_item->get_data( ).


*-- Portability: REVOK is space or numeric


       l_num = ls_erevitem-revno.


       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_erevitem-revno.


         l_date1     = ls_erevitem-erdat.


         l_time1     = ls_erevitem-eruhr.


       ENDIF.


       IF l_num GT l_num_max


       OR l_revno_max IS INITIAL.


         l_revno_max = ls_erevitem-revno.


       ENDIF.


     ENDLOOP.


if sy-subrc = 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             = SY-TCODE


     IMPORTING


       CHECK           = C.


ELSE.


   MESSAGE i000(zlng) .


   EXIT.


ENDIF.


IF  C = 'X'.


MESSAGE s002(zlng) WITH ls_erevitem-revno.


IF ls_erevitem-ZZTEXT1 IS INITIAL.


  ls_erevitem-ZZTEXT1 = 'X'.


  ELSE.


    CLEAR ls_erevitem-ZZTEXT1.


    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

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

         Click on the Long Text ICON as shown below

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

Thanks & Regards,

S.Rajendranath