Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
S0024924847
Explorer

Prerequisite -


In our day to day Business activity we may come across on a scenario where User wants to updates the Text Log from outside of SolMan portal. In order to update the Text Log via some custom program or Interface is possible using standard function module "SAVE_TEXT".

Below the snapshot of On Normal Change ChaRM ID with Initial Text Log entries.



Process & Steps -


Here I am trying to explain with small custom program, which help you to update the Text Log area with different type of "Add Text".

Step 1 -


Below the Selection screen of Custom Report allow you to enter the ChaRM ID and Text Comments. Also select the type of "Add Text Type" you wants to update in the Text Log of respective ChaRM ID.


With Respect to Text Log Type available in SolMan -



Step 2 -


After filling up click on "Execute" button. This will update the inserted text into the ChaRM ID respective Text Log section.



Example  -


This sample ChaRM ID - 8000005536 respective current status


 Text Log entries when it was created.


Now go to Program and enter the ChaRM ID and Text which we want to update in the Text Log section along with Text Type.


Custom Report Output -


Now Check at the ChaRM ID respective Log Text section should update "General Note" .



Verification of Data updated Successfully -


For Cross Check go to SAP table - CRMD_ORDERADM_H put ChaRM ID and get the GUID value


Now go to Table STXH put GUID value in TDNAME


Get the latest TDNAME then go to Function Module - READ_TEXT


Fill the Function Module Import Parameter section -


After execution check the Table "LINES"  has one entry.


Table - LINES value and Respective ChaRM ID related Text Log entry



Source Code -



                   Custom Program Text Elements & Selection Text section -




Sample of code in plain Text Format -


**************************************************************

*&---------------------------------------------------------------------*
*& Report  YTEST_SH01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ytest_sh01.

DATA: lv_guid           TYPE crmt_object_guid,
      lt_initial_text   TYPE  tline,
      lv_header         TYPE thead,
      lv_tdname         TYPE tdobname,
      lv_timestring     TYPE string,
      lv_datetime       TYPE c LENGTH 38,
      lv_guid_stg       TYPE string,
      lt_text_lines     TYPE TABLE OF tline,
      lt_text_lines_new TYPE TABLE OF tline,
      lv_timestamp      TYPE timestampl,
      lv_text(4)        TYPE c.

CONSTANTS: lc_text1(4) TYPE c VALUE 'CD03', " General Note
           lc_text2(4) TYPE c VALUE 'CD01', " Test Report
           lc_text3(4) TYPE c VALUE 'CR01', " Description of Change
           lc_text4(4) TYPE c VALUE 'CR02', " Reason for Change
           lc_text5(4) TYPE c VALUE 'CR04', " Effect on System(s)
           lc_text6(4) TYPE c VALUE 'CD02'. " Test Instruction

SELECTION-SCREEN BEGIN OF BLOCK part4 WITH FRAME TITLE text-002.
PARAMETERS: r1 RADIOBUTTON GROUP rad1,                  " Description of Change
            r2 RADIOBUTTON GROUP rad1,                  " Reason for Change
            r3 RADIOBUTTON GROUP rad1,                  " Effect on System(s)
            r4 RADIOBUTTON GROUP rad1,                  " Test Instruction
            r5 RADIOBUTTON GROUP rad1,                  " Test Report
            r6 RADIOBUTTON GROUP rad1 DEFAULT 'X'.      " General Note
SELECTION-SCREEN END OF BLOCK part4.

SELECTION-SCREEN BEGIN OF BLOCK part1 WITH FRAME TITLE text-001.

PARAMETERS: obj_id TYPE crmd_orderadm_h-object_id,
            p_text TYPE string LOWER CASE.

SELECTION-SCREEN END OF BLOCK part1.

 

SELECT guid
  FROM  crmd_orderadm_h INTO lv_guid
    WHERE object_id = obj_id.
ENDSELECT.

IF sy-subrc = 0.
  lv_guid_stg = lv_guid.
ENDIF.
GET TIME STAMP FIELD lv_timestamp.
lv_timestring = lv_timestamp.

CONCATENATE lv_timestring+0(14) lv_timestring+15(3) INTO lv_datetime.
SHIFT lv_datetime BY 21 PLACES RIGHT.
CONCATENATE lv_guid_stg lv_datetime  INTO lv_tdname.   "  Fprmater for STXH table

lt_initial_text-tdline = p_text.
lt_initial_text-tdformat = '*'.
APPEND lt_initial_text TO lt_text_lines.

lt_text_lines_new[] = lt_text_lines[].

IF r1 = 'X'.
  lv_text = lc_text3.
ELSEIF  r2 = 'X'.
  lv_text = lc_text4.
ELSEIF  r3 = 'X'.
  lv_text = lc_text5.
ELSEIF  r4 = 'X'.
  lv_text = lc_text6.
ELSEIF  r5 = 'X'.
  lv_text = lc_text2.
ELSEIF  r6 = 'X'.
  lv_text = lc_text1.

ENDIF.

CALL FUNCTION 'INIT_TEXT'
  EXPORTING
    id       = lv_text
    language = 'E'
    name     = lv_tdname
    object   = 'CRM_ORDERH'
  IMPORTING
    header   = lv_header
  TABLES
    lines    = lt_text_lines
  EXCEPTIONS
    id       = 1
    language = 2
    name     = 3
    object   = 4
    OTHERS   = 5.

 

CALL FUNCTION 'SAVE_TEXT'
  EXPORTING
    header          = lv_header
    savemode_direct = 'X'
  TABLES
    lines           = lt_text_lines_new
  EXCEPTIONS
    id              = 1
    language        = 2
    name            = 3
    object          = 4
    OTHERS          = 5.

IF sy-subrc =  0.
ENDIF.

IF sy-subrc = 0.
  WRITE:/ 'Charm Id update                      :         ',obj_id.
  WRITE:/ 'Charm GUID                           :         ', lv_guid.
  WRITE:/ 'Update the Log of above Charm with   :      ', p_text.
  WRITE:/ 'Text Table Entry ID                  : ', lv_tdname.
ENDIF.

************************************************************************************************


Additional Information -


For Text ID Type and respective value go to T-code - SE75 then click on "Display" Then select "CRM_ORDERH" will gives you the Text Description along with the Text ID.




Conclusion -


This sample code will help developer to enhance the SolMan ChaRM ID relevant Text Log update as per business needs. The corresponding entry get stored table - STXH with correct prescribed format TDNAME [ Format created during runtime] and you can Validate this output using Function Module - READ_TEXT with Text Table Entry ID generated via custom program.

 

For More Relevant Custom Enhancement related to SolMan visit below links:

SOLMAN – How to get SAP Tables name stored ChaRM ID mapping between Change Cycle / Phase and Configu...

SOLMAN – SAP Table used to stored ChaRM Process Type & Change Cycle ID. | SAP Blogs

SAP ChaRM Git-Enable Change used Table to stored Commit Id Details | SAP Blogs


 

 
2 Comments
thalesvb
Active Contributor
Hey, even though this works, the philosophy of directly using READ_TEXT/SAVE_TEXT (underlying API) is not a happy choice since it creates an actual security hole: it doesn't check if the user is entitled to modify that document (CRM_ORD_* authorizations) with that specific Text Type (CRM_TXT_ID authorization) at all, not to say doesn't even checks if Text Type is actually "active" on related Change Document Text Procedure, so an "invalid" input will be actually stored on system. A safer choice would be CRM_TEXT_MAINTAIN_OW / CRM_TEXT_SAVE_OB (CRM_TEXT function group) since those actually do the required checks.

KR
vigneshprabhu
Active Participant
0 Kudos
Excellent blog, would be useful for many.

Well explained souman1110

Regards,

Vignesh
Labels in this area