Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all 935 articles
Browse latest View live

Global Class and Method for Application Log

$
0
0

The goal of the object is to create the Global Class and Method for Application Log so that it can be reused where necessary in any RICEF object.

 

Application Log provides an infrastructure for collecting messages and exceptions in a log, saving, reading and deleting logs in the database and displaying them.

 

Application Log provides multiple advantages:

  • System-wide uniform event logging
  • Accessible standardized UI based on ABAP List Viewer (ALV)
  • High capabilities for analysis of log data  

 

Application logging records the progress of the execution of an application. Whereas the system log records system events, you can use the application log to record application-specific events.

 

Application Log is designed to temporarily store messages. Logs should be deleted in intervals (e.g. weekly batch job for deleting logs) to avoid too high database load.

 

A typical use of the Application Log is within delivery processing. Negative results of a dangerous goods check are written to the Application Log. Application messages and reactions are collected based on a customer defined examination schema (reactions determine how the document will be handled further). This approach increases the transparency of the process for end users. Messages are collected temporarily and are not saved to the database.


First create object and sub object, Go to transaction SLG0.

Go to change mode and click on New entries button on the application tool bar. 


1.jpg

Then define the sub object for the object.

Select the object and double click on sub object.

2.jpg

Create Global Class and Method to define the Application log code

3.jpg


Define the following Parameter in Method

6.jpg

Define following Data in the Method

7.jpg

Populate the Header data with the following details

8.jpg

Create the log with FM BAL_LOG_CREATE

9.jpg

Add all the message in the log using FM BAL_LOG_MSG_ADD

10.jpg

Save the Log using FM BAL_DB_SAVE

11.jpg

Display the log using FM  BAL_DSP_LOG_DISPLAY

12.jpg

Define that Class and method in the code wherever necessary

4.jpg


The Method will create log with all the messages and generate log (Transaction SLG1)


5.jpg

Code is attached.


To Display Custom Field in BOM transactions CS01, CS02, CS03, CS11, CS12, CS13

$
0
0

Introduction

 

This document explains how to display a customer field in the BOM transactions CS01, CS02, CS03, CS11, CS12, and CS13 in ECC 6.0 EHP 5. The requirement is to display a custom field from the MARA table, ZZ_OLD_MATERIAL.

 

CS11

 

First, let's look at CS11. The program for CS11 is RCS11001. The ALV Grid is displayed in the output of CS11 by a call to FM REUSE_ALV_GRID_DISPLAY in Subroutine CS11_ALV of program RCS11001.

 

a1.png

 

Note the t_outtab parameter in TABLES is assigned alv_stb. Also, the it_fieldcat parameter in EXPORTING is assigned stb_fields_tb.

 

In order to add ZZ_OLD_MATERIAL to CS11 we need to do three things:

  1. Add ZZ_OLD_MATERIAL to the output table alv_stb
  2. Populate ZZ_OLD_MATERIAL in alv_stb with values from MARA
  3. Add ZZ_OLD_MATERIAL to the field catalog table stb_fields_tb

 

1. Add ZZ_OLD_MATERIAL to the output table alv_stb

 

Internal table alv_stb is defined as follows:

 

b1.png

 

Structure STPOX_ALV has a means of adding customer fields to it in Include structure CI_STPO.

 

c1.png

 

Double-click CI_STPO to create the structure. Enter ZZ_OLD_MATERIAL as a Component.

 

d1.png

 

Check and Activate Structure CI_STPO. This may take some time as CI_STPO is used in many tables.

 

Now ZZ_OLD_MATERIAL is a field in alv_stb.

 

2. Populate ZZ_OLD_MATERIAL in alv_stb with values from MARA

 

The alv_stb table is populated from internal table stb in the following lines of code from subroutine CS11_ALV:

 

e1.png

 

If you check how stb is defined you will notice that ZZ_OLD_MATERIAL is available to us.

 

Click the Enhance icon, then select menu option Edit>Enhancement Operations>Show Implicit Enhancement Options.

 

f1.png

 

Right click on the """"""" and select Enhancement Operations>Create Implementation.

 

g1.png

 

Click Declaration for Type of Enhancement.

 

h1.png

 

Click the Create Enhancement Implementation icon.

 

i1.png

 

Enter a name for the Enhancement Implementation and Short Text. I entered Z_RCS11001_1.

 

j1.png

 

Select your Enhancement Implementation

 

Enter the following code between ENHANCEMENT and ENDENHANCEMENT:

 

k1.png

 

Save, Check, and Activate the Enhancement.

 

This will populate stb- ZZ_OLD_MATERIAL which will get passed to alv_stb- ZZ_OLD_MATERIAL in PERFORM alv_stb_prep.

 

3. Add ZZ_OLD_MATERIAL to the field catalog table stb_fields_tb

 

The field catalog, stb_fields_tb, is set in subroutine stb_fields_tb_prep. We need to enhance the subroutine so that CS11 will display ZZ_OLD_MATERIAL. The following screenshot shows the place for the Implicit Enhancement at the end of FORM stb_fields_tb_prep.

 

l1.png

 

Right click on the """"""" and select Enhancement Operations>Create Implementation.

Click Declaration for Type of Enhancement.

You can use the same Implementation created earlier. This will be Enhancement 2. Enter the following code between ENHANCEMENT and ENDENHANCEMENT:

 

m1.png

 

Save, Check, and Activate the Enhancement.

 

Now our custom field is in the field catalog to be displayed in column 5.

 

Execute CS11 to see the new field.

 

CS12 and CS13

 

You will need to do the same Enhancements for CS12 and CS13. CS12 uses program RCS12001. The FORMs to Enhance are called CS12_ALV and STB_FIELDS_TB_PREP. CS13 uses program RCS13001 and the FORMs are CS13_ALV and STB_FIELDS_TB_PREP. When you Enhance STB_FIELDS_TB_PREP in RCS12001 and RCS13001, make note of the fields that are displayed because they are different than RCS11001.

 

CS01, CS02, and CS03

 

After making the changes above for CS11, CS12, and CS13 I executed CS03 and noticed ZZ_OLD_MATERIAL on the standard screen of the Material tab (screen 0152) to the right of the Group (Grp) field. I thought I would have to use Enhancement PCSD0002 to display my custom field in CS03. PCSD0002 is the Enhancement to add your own BOM item fields. But I didn't like that PCSD002 would display my custom field on a new tab other than Material. This field was for display purposes only so I didn't need to worry about changing the field value. Now I just needed to populate it.

 

In Function Group CSDI, open Include LCSDIFFK. There you will see FORM STPOB_LESEN with a call to function module CS_BT_STOB_READ.

 

n1.png

 

Note the FM returns structure STPOB. STOB already has ZZ_OLD_MATERIAL as a field.

 

Create an Implicit Enhancement at the end of the FORM. Enter the following code between ENHANCEMENT and ENDENHANCEMENT:

 

o1.png

 

Save, Check, and Activate the Enhancement.

 

Still need to Activate Enhancement PCSD0002.

 

For some reason we still have to Activate PCSD0002. Actually, it's because of the line 85 below in FORM D0150_INIT_02 in Include LCSDIF3Z:

 

p1.png

 

If PCSD0002 is not Active, the program will not fill field <D0152-FS1> (our custom field) from stpob-ZZ_OLD_MATERIAL in the subsequent lines of the form.

 

Activating PCSD0002

 

Go to CMOD and create a Project. Add Enhancement PCSD0002. We have to create screen 1000 so go to the Components.

 

q1.png

 

Double click screen 1000. All that is needed is a Short Description and to change the Screen Type to Subscreen.

 

Save, Check, and Activate the screen.

 

Different original and logon languages

 

You may now get several pop-up messages regarding different original and logon languages.

 

r1.png

 

At the 'Different original and logon languages' pop-up click Change orig. language.

 

r2.png

 

Click Continue.

 

r3.png

 

Click the green check.

 

r4.png

 

Click the green check.

 

r5.png

 

Finally, click Yes.

 

Activate the Project.

 

You do not need to place any code in the EXIT FMs. This custom field is for display only.

 

ExecuteCS01, CS02, CS03 and you should see your custom field populated on the standard screen of the Material tab.

How to use VBScript Inside ABAP and Store VBScript Source as Include

$
0
0

Hello community,

 

in different postings I show the possibilities to use different languages with ABAP, e.g. here.

 

Here now an example how to use VBScript inside ABAP and how to store the VBScript source as include.

 

At first create a new include, e.g with the name ZVBSCRIPT001:

 

'-Begin-----------------------------------------------------------------

 

  '-Directives----------------------------------------------------------

    Option Explicit

 

  '-Function plus-------------------------------------------------------

    Function plus(val1, val2)

      plus = val1 + val2

    End Function

 

  '-Function minus------------------------------------------------------

    Function minus(val1, val2)

      minus = val1 - val2

    End Function

 

  '-Function plusminus--------------------------------------------------

    Function plusminus(val1, val2, val3)

      Dim res

      res = plus(val1, val2)

      plusminus = minus(res, val3)

    End Function

 

'-End-------------------------------------------------------------------

 

As you can see, it is a collection of VBScript functions. Don't forget to activate this include. If an error occurs, ignore it.

 

Now create a new function module, e.g. with the name ZREADVBCODE:

 

"-Begin-----------------------------------------------------------------

  Function ZREADVBCODE .


*"--------------------------------------------------------------------

*"*"Lokale Schnittstelle:

*"  IMPORTING

*"     VALUE(I_INCLNAME) TYPE  SOBJ_NAME

*"  EXPORTING

*"     VALUE(E_STRINCL) TYPE  STRING

*"--------------------------------------------------------------------

 

    "-Variables---------------------------------------------------------

      Data resTADIR Type TADIR.

      Data tabIncl Type Table Of String.

      Data lineIncl Type String Value ''.

      Data strIncl Type String Value ''.

 

    "-Main--------------------------------------------------------------

      Select Single * From TADIR Into resTADIR

        Where OBJ_NAME = I_InclName.

      If sy-subrc = 0.

 

        Read Report I_InclName Into tabIncl.

        If sy-subrc = 0.

          Loop At tabIncl Into lineIncl.

            If lineIncl <> ''.

 

              "-Trim leading and trailing spaces------------------------

                Condense lineIncl.

 

              "-If line is no comment-----------------------------------

                If lineIncl+0(1) <> ''''.

                  Concatenate strIncl lineIncl

                    cl_abap_char_utilities=>cr_lf Into strIncl.

                EndIf.

 

              lineIncl = ''.

 

            EndIf.

          EndLoop.

        EndIf.

 

      EndIf.

      E_strIncl = strIncl.

 

  EndFunction.

 

"-End-------------------------------------------------------------------

 

This function module reads an include and delivers the content of the include as string.

 

As last source the program ZVBSCRIPT:

 

"-Begin-----------------------------------------------------------------

  Report zVBScript.

 

    "-Type pools--------------------------------------------------------

      Type-Pools OLE2.

 

    "-Variables---------------------------------------------------------

      Data ScriptCtrl Type OLE2_OBJECT.

      Data Result Type Integer.

      Data InclCode Type String Value ''.

 

    "-Main--------------------------------------------------------------

      Create Object ScriptCtrl 'MSScriptControl.ScriptControl'.

 

      If sy-subrc = 0 And ScriptCtrl-Handle <> 0 And

        ScriptCtrl-Type = 'OLE2'.

 

        "-Allow to display UI elements----------------------------------

          Set Property Of ScriptCtrl 'AllowUI' = 1.

 

        "-Intialize the VBScript language-------------------------------

          Set Property Of ScriptCtrl 'Language' = 'VBScript'.

 

        "-Read Visual Basic Script code from include file---------------

          Call Function 'ZREADVBCODE'

            Exporting I_InclName = 'ZVBSCRIPT001'

            Importing E_strIncl = InclCode.

 

         "Include ZVBSCRIPT001.

 

        Call Method Of ScriptCtrl 'AddCode' Exporting #1 = InclCode.

 

        If sy-subrc = 0.

 

          Call Method Of ScriptCtrl 'Eval' = Result

            Exporting #1 = 'plusminus(32, 16, 8)'.

 

          Write: / Result. "Result = 40

 

        EndIf.

 

        "-Free the object-----------------------------------------------

          Free Object ScriptCtrl.

 

      EndIf.

 

"-End-------------------------------------------------------------------

 

It creates an Visaul Basic Script Control and reads the include ZVBSCRIPT001. It adds the source from the include and with the method Eval we execute the VBScript function plusminus.

 

With this way it is very easy to integrate and to use VBScript sources with the SAP development workbench. So it is much more handier as the concatenation of a string with a macro - like in my other examples. This paves the way for an easy polyglot programming.

 

Cheers

Stefan

Q2R (Query 2 Report) / a quick way to make reports

$
0
0

Hi developers,

 

I want to share with you a new way of doing reports. This tool allows you to create reports in 2 minutes. ZQ2R creates quickly reports from a query. The selection screen, selection texts and code are automatically generated.

 

The ZQ2R code is attached to this post.

 

An example is shown below.

 

The Query (SQVI)

 

After running ZQ2R, press the QuickViewer button

01 - q2r - selection screen.jpg

Here we will create a query to see the flights from New York City.

02 - FlightsFrom_NY.jpg

After you input the query’s name  (FlightsFrom_NY) press the button Create.

In this example we will use the data source “Table join”.

03 - Data source.jpg

Press the insert table button to add the following tables: SPFLI (Flight schedule), SFLIGHT (Flight) and SCARR (Airline).

04 - insert table.jpg

05 - insert table popup.jpg

Once selected the three tables, press the back button (F3).

06 - Data source.jpg

Set the displayed fields and selection fields.

07 - Fields displayed.jpg

After selecting the report fields, you can set the sort sequence.

08 - Sort sequence.jpg

Finally save the query and get the report name.

17 generate program.jpg

10 - Display report name.jpg

11 - Reort name.jpg

ZQ2R

 

Copy and paste the assigned report (AQ01SYSTQV000001FLIGHTSFROM_NY)

12 - q2r.jpg

After running ZQ2R, set the selection fields behavior.

13 - Selection fields.jpg

You can also define default values ​​by clicking the corresponding check box.

14 - Default Value.jpg

By clicking the “Sel. Text” column you can edit the selection texts.

15 - Selection texts.jpg

Finally press the back button and the zq2r_flightsfrom_ny report will be created!

21.jpg

Now, you can run the newly created report from SE38 transaction

22.jpg

19.jpg

20.jpg

The automatically generated code (zq2r_flightsfrom_ny):

 

*&-----------------------------------------------------------------*

*& Report ZQ2R_FLIGHTSFROM_NY

*&-----------------------------------------------------------------*

REPORT zq2r_flightsfrom_ny.

 

*&-----------------------------------------------------------------*

*&  Include ZQ2R_FLIGHTSFROM_NY_TOP

*&-----------------------------------------------------------------*

CONSTANTS:

  c_cityfr TYPE spfli-cityfrom VALUE 'NEW YORK'.

 

TABLES:

  spfli,

  sflight.

 

TYPES:

  tyr_carrid TYPE RANGE OF spfli-carrid,

  tyr_fldate TYPE RANGE OF sflight-fldate,

 

  BEGIN OF ty_data,

    cityfrom TYPE spfli-cityfrom,

    cityto   TYPE spfli-cityto,

    carrname TYPE scarr-carrname,

    fldate   TYPE sflight-fldate,

  END OF ty_data,

  tyt_data TYPE STANDARD TABLE OF ty_data.

 

DATA t_data TYPE STANDARD TABLE OF ty_data.

*&-----------------------------------------------------------------*

*&  Include ZQ2R_FLIGHTSFROM_NY_SEL

*&-----------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME.

 

PARAMETER p_cityfr TYPE spfli-cityfrom DEFAULT c_cityfr.

SELECT-OPTIONS s_carrid FOR spfli-carrid MEMORY ID car.

SELECT-OPTIONS s_fldate FOR sflight-fldate MEMORY ID day OBLIGATORY.

 

SELECTION-SCREEN END OF BLOCK a.

*&-----------------------------------------------------------------*

*&  Include ZQ2R_FLIGHTSFROM_NY_F01

*&-----------------------------------------------------------------*

*&-----------------------------------------------------------------*

*&      Form  SET_SELECTION_FIELD_DISABLED

*&-----------------------------------------------------------------*

FORM set_selection_field_disabled USING p_spname TYPE aqs_spname.

 

  DATA lv_spname_length TYPE i.

 

  lv_spname_length = strlen( p_spname ).

 

  LOOP AT SCREEN.

    IF screen-name(lv_spname_length) = p_spname.

      screen-input = 0.

      MODIFY SCREEN.

    ENDIF.

  ENDLOOP.

 

ENDFORM.                    " SET_SELECTION_FIELD_DISABLED

 

*&-----------------------------------------------------------------*

*&      Form  GET_DATA

*&-----------------------------------------------------------------*

FORM get_data USING p_cityfr TYPE spfli-cityfrom

                    s_carrid TYPE tyr_carrid

                    s_fldate TYPE tyr_fldate

           CHANGING t_data   TYPE tyt_data.

 

 

  SELECT spfli~cityfrom

         spfli~cityto

         scarr~carrname

         sflight~fldate

    FROM ( spfli

           INNER JOIN sflight

           ON  sflight~carrid = spfli~carrid

           AND sflight~connid = spfli~connid

           INNER JOIN scarr

           ON  scarr~carrid = sflight~carrid )

    INTO TABLE t_data

         WHERE spfli~cityfrom = p_cityfr

           AND spfli~carrid IN s_carrid

           AND sflight~fldate IN s_fldate .

 

ENDFORM.                    " GET_DATA

 

*&-----------------------------------------------------------------*

*&      Form  ALV

*&-----------------------------------------------------------------*

FORM alv USING t_data TYPE tyt_data.

 

  DATA:

    o_sorts     TYPE REF TO cl_salv_sorts,

    o_columns   TYPE REF TO cl_salv_columns,

    o_display   TYPE REF TO cl_salv_display_settings,

    o_functions TYPE REF TO cl_salv_functions_list,

    o_layout    TYPE REF TO cl_salv_layout,

    ls_key      TYPE        salv_s_layout_key,

    o_alv       TYPE REF TO cl_salv_table.

 

* Gel ALV object

  TRY.

      cl_salv_table=>factory(

        IMPORTING

          r_salv_table = o_alv

        CHANGING

          t_table      = t_data ).

    CATCH cx_salv_msg.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDTRY.

 

* ALV Sort

  o_sorts = o_alv->get_sorts( ).

  TRY.

      o_sorts->add_sort( 'CITYFROM' ).

      o_sorts->add_sort( 'CITYTO' ).

      o_sorts->add_sort( 'CARRNAME' ).

      CALL METHOD o_sorts->add_sort

        EXPORTING

          columnname = 'FLDATE'

          sequence   = if_salv_c_sort=>sort_down.

    CATCH cx_salv_not_found

          cx_salv_existing

          cx_salv_data_error.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDTRY.

 

* Get columns

  o_columns = o_alv->get_columns( ).

* Set the column optimization

  o_columns->set_optimize( ).

 

  o_display = o_alv->get_display_settings( ).

  o_display->set_striped_pattern( abap_true ).

 

* Generic ALV functions

  o_functions = o_alv->get_functions( ).

  o_functions->set_all( ).

 

* Layout

  o_layout = o_alv->get_layout( ).

  ls_key-report = sy-repid.

  o_layout->set_key( ls_key ).

  o_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).

 

  o_alv->display( ).

 

ENDFORM.                    " ALV

 

AT SELECTION-SCREEN OUTPUT.

  PERFORM set_selection_field_disabled: USING 'P_CITYFR'.

 

START-OF-SELECTION.

  PERFORM get_data USING p_cityfr

                         s_carrid[]

                         s_fldate[]

                CHANGING t_data.

 

END-OF-SELECTION.

  PERFORM alv USING t_data.

Step by step to create, consume and trace web service in ABAP system

$
0
0

This document could be used as guide for beginners to learn and use ABAP web service.

 

How to create web service provider in ABAP system


The following steps demonstrates how to expose a function module as a web service provider in SAP CRM system.

 

 

1. create a new function module to return product description by given input product ID.

 

Signature and source code of function module:

 

FUNCTION ZGET_PROD_DESCRIPTION.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IV_PROD_ID) TYPE  COMM_PRODUCT-PRODUCT_ID
*"  EXPORTING
*"     VALUE(RV_TEXT) TYPE  STRING
*"----------------------------------------------------------------------
SELECT SINGLE A~short_text INTO rv_text FROM COMM_PRSHTEXT  AS A  INNER JOIN comm_product AS B ON B~product_id = iv_prod_id AND B~product_guid = A~product_guid.
ENDFUNCTION.

Make sure the FM is marked as "Remote enabled".

clipboard1.png

2. start the web service creation wizard:

clipboard2.png

Just follow the wizard to finish creation. Choose the appropriate authentication approach according to your use case.

clipboard3.png

3. Once creation is finished, you would find your service definition as below:

clipboard4.png

click tab WSDL, write down your WSDL link:

clipboard5.png

4. use tcode SOAMANAGER, click Web Service Configuration

clipboard6.png

you can find your service definition created just now:

clipboard7.png

click the hyperlink and create a new service:

clipboard8.png

For security reasons choose radio box "SSL".

clipboard9.png

click Finish button:

clipboard10.png

Now your web service is ready for consumption. click this icon:

clipboard11.png

write down this link for later usage:

clipboard12.png

How to consume web service in ABAP system

1. tcode SE80, create a new service consumer:

clipboard14.png

2. Choose external WSDL:

clipboard15.png

choose the url got from last step of chapter "How to create web service provider in ABAP system":

clipboard16.png

activate your consumer proxy and write down the ABAP class name.

clipboard17.png

3. go back to SOAMANAGER, find the consumer proxy created in step2:

clipboard18.png

create a new logical point:

clipboard19.png

clipboard20.png

4. Make sure you specify URL got from the last step of web service creation chapter. If you just use the URL got from SE80 in tab "WSDL", you will meet with below error.

clipboard21.png

choose HTTPS:

clipboard22.png

5. consume the web service in ABAP report:

 

you can find the data type for input and output parameters in SE80:

clipboard22.png

data: lr_proxy TYPE REF TO CO_ZPRODUCTDESCRIPTION4,
input TYPE ZGET_PROD_DESCRIPTION,
output TYPE ZGET_PROD_DESCRIPTION_RESPONSE.
input-iv_prod_id = 'ARNO_TEST004'.
CREATE OBJECT lr_proxy     EXPORTING            LOGICAL_PORT_NAME = 'ZLP_JERRY1'.
CALL METHOD lr_proxy->ZGET_PROD_DESCRIPTION     EXPORTING            input = input     IMPORTING            output = output.

Now we execute the report and get the web service execution result as expected:

clipboard23.png


The product description in UI:

clipboard24.png

How to trace the web service execution


Use tcode SRT_UTIL, add a new configuration for your user which triggers the web service call:

clipboard26.png

Set the Functional Trace to "High". You could also enable Performance and Payload trace if necessary.

Click Save Configuration button to persist the change.

clipboard27.png

Execute the report which triggers the web service call. After it finishes, click tab "Functional Trace" and click refresh button, you should see several records for execution trace.

clipboard28.png

Double click and select the row with type "Response", where you could find the product description value returned by service provider.

clipboard29.png

Restricting Company Code Popup in FB50 via ABAP Code

$
0
0

This document explains how to restrict the company code popup in FB50 transaction through ABAP code.

SAP has a standard system behavior which enables the user to enter the value in company code popup in FB50 transaction. There may be exceptional cases,

where two different files of the same country has to be uploaded in sequence. This will result in error while processing the BDC sessions,

since same company code is passed as input.

Solution:

Consider a scenario,where we create two BDC sessions for overall screen processing and company code popup to post a document via FB50.

When two different files of same country are executed in sequence,

Say for India, we will input the same company code value in the popup, which restricts further processing.

In such cases, we need to capture the values of  the recent session created from gthe  table TFBUF.

 

TFBUF- FI Data Table.

This table acts as a buffer for FI transactions.

Untitled.png

Compare the values with current session and make a condition check with respect to the company code value and current user.

We can also include the condition in the query with application type of the document being posted.

geg.png   

 

Program Code:

 

     tb_buf   TYPE STANDARD TABLE OF tfbuf,
     wa_buf  TYPE tfbuf.  

 

Select * from tfbuf
       into table tb_buf
       WHERE usnam = sy-uname AND
                     applk = ‘GL’.    
READ TABLE tb_buf into wa_buf index 1.
if wa_buf-buffr+1(3) = p_code.        “p_code is the Company code value passed
  lv_flag = ‘X’.                               “Condition check to skip the session
Endif.

 

Now, based on the company code values used, we can check the condition and skip the BDC session created for Company code popup, thereby allowing the system to continue the process.

 

Before Changes:

 

When we try to pass the same company code in the popup, the system will not allow the user to process further, since the previous value is stored in the buffer.

SGv.png

 

 

After Changes:

 

Company code popup is skipped and the session is created successfully.

Untitled.png

Learn more detail about Standard logon procedure

$
0
0

The motive to write this document is that during I deal with a HTTP 401 unauthorized error( detail explained in this document ), I would like to learn more about SAP standard logon procedure.

 

Use tcode SICF, navigate to icf node and click F1 on Procedure field, then we can find the documentation for Standard Logon Sequence.

clipboard1.png

The sequence of log on check in standard logon procedure are defined in SAP help:


  1. Logon using HTTP fields
  2. Logon with SSL certificates
  3. Logon using SAP Logon Ticket (‘SSO’)
  4. HTTP Basic Authentication
  5. Logon using SAP user password (SAP RFC logon)
  6. Logon using SAML
  7. Logon using user data stored in the service

 


So I would like to play around with these log on orders.

 

Case1: Directly open WSDL url in browser

 

The WSDL URL is: http://<XXXX>:50078/sap/bc/srt/wsdl/flv_10002A111AD1/bndg_url/sap/bc/srt/rfc/sap/zws_add/506/zjerry1/jerry1?sap-client=506

 

After I paste it into browser address bar and press enter key, I could see the expected WSDL content. However I observed a HTTP 307 redirect in HTTP watch, and the final url in browser is also automatically changed to https.

clipboard2.png

This redirect behavior is defined in parameters which could be found in tcode SMICM

clipboard3.png

or RZ11 use parameter name icm/HTTP/redirect_0:

clipboard4.png

In this case, I didn't specify any user & password but still I could get the WSDL content. According to SAP help "Logon using SAP Logon Ticket (MYSAPSSO2 cookie field). If no logon data is transferred as form fields or header fields, the system then tries to log on using a logon ticket. To enable this, the cookie field MYSAPSSO2 must be set."

 

I could observe this Logon ticket usage in client side via HTTP watch:

clipboard5.png

If I disable my Certificate in browser settings via "Tools->Internet Settings->Content->Certificates" and then re launch the WSDL url in browser:

clipboard6.png

This time I observed a 401 unauthorized error in HTTP watch, accompanied with a pop up window asking for user and password.

clipboard7.png

After I input my user and password, I could see the WSDL content ( http response code: 200 ).

This time I could see The authorization method is changed to "Basic d2FuZ2plcjpTYXAxMjM0NQ==",

clipboard8.png

The string "d2FuZ2plcjpTYXAxMjM0NQ==" is the Base64 encoding result on the concatenation of user name and password I input with ":":

clipboard9.png

Case2: Access WSDL via cl_http_client by code

 

I list the following scenarios about access to external WSDL url via ABAP code. Some might not be used in productive usage, but just used for study and verification purpose.

 

Variant a: none credentials specified in code

 

Execute the following small piece of code:

DATA:    lo_http_client TYPE REF TO if_http_client,         lv_status      TYPE i,         lv_sysubrc     TYPE sysubrc,         lv_url         TYPE string.
lv_url = 'http://<XXXX>:50056/sap/bc/srt/wsdl/flv_10002A111AD1/bndg_url/sap/bc/srt/rfc/sap/zweb_add/001/zweb_add/add?sap-client=001'.
CALL METHOD cl_http_client=>create_by_url  EXPORTING    url                = lv_url  IMPORTING    client             = lo_http_client  EXCEPTIONS    argument_not_found = 1    plugin_not_active  = 2    internal_error     = 3    OTHERS             = 4.
ASSERT sy-subrc = 0.
lo_http_client->request->set_method( if_http_request=>co_request_method_get ).
CALL METHOD lo_http_client->send  EXCEPTIONS    http_communication_failure = 1    http_invalid_state         = 2    http_processing_failed     = 3.
ASSERT sy-subrc = 0.
CALL METHOD lo_http_client->receive  EXCEPTIONS    http_communication_failure = 1    http_invalid_state         = 2    http_processing_failed     = 3.
IF sy-subrc <> 0.  CALL METHOD lo_http_client->get_last_error    IMPORTING      code    = lv_sysubrc      message = DATA(ev_message).  WRITE: / lv_sysubrc, 'error message:', ev_message COLOR COL_NEGATIVE.  RETURN.
ENDIF.
WRITE: / 'WSDL got successful' COLOR COL_POSITIVE. 

 

 

Once executed, the expected popup window appears since I didn't specify any credentials in the code:

clipboard10.png

After I input the correct user and password, the code could successfully return the WSDL.

 

Variant b: disable the popup in code

 

The popup behavior could be suppressed via code lo_http_client->propertytype_logon_popup = if_http_client=>co_disabled. This new line must be added before send method is called.

 

Execution result: No popup window, and the call of lo_http_client->response->get_cdata( ) returns the following error html page:

clipboard11.png

Variant c: add code to support basic authentication

 

Add the following code before lo_http_client->send():

lo_http_client->request->set_authorization(

                   auth_type  = ihttp_auth_type_basic_auth

                   username   = 'WANGJER'

                   password   = 'Sap12345' ).

And WSDL content returned as expected:

clipboard12.png

Variant d: initialize http client via HTTP destination instead of url

 

Create a HTTP destination in tcode SM59:

clipboard13.png

 

Maintain the necessary user name and password for logon:

clipboard14.png

Then use method create_by_destination to initialize the http client instance. In this way it is not necessary to specify any credentials in ABAP code.

 

CALL METHOD cl_http_client=>create_by_destination
  EXPORTING
    destination        = 'ZWS'
  IMPORTING
    client             = lo_http_client
  EXCEPTIONS
    argument_not_found = 1
    plugin_not_active  = 2
    internal_error     = 3
    OTHERS             = 4.

 

Variant e: directly append user and password in url

clipboard15.png

Variant f: log on via SAP Logon Ticket

 

copy the value of Cookie field MYSAPOSS2 from HTTP watch into ABAP code:

clipboard16.png

clipboard17.png

Let's Find Cloned Programs!

$
0
0

Hello All,

 

Cloned programs give major headache and maintenance issues when we go for an upgrade.

Before writing this program i have gone through various documents and threads which explains clone hunting in various methods.

 

http://scn.sap.com/thread/1539774

http://wiki.scn.sap.com/wiki/display/ABAP/Clone+hunter

http://scn.sap.com/community/abap/blog/2009/03/27/simple-abap-clone-hunter

 

My conclusion was to use the SAP standard way. If the system status meets the below criteria.

 

"System --> Status and you should see ST-PI 2008_1_XXX, which could be one of the following:

2008_1_46C,   2008_1_620,   2008_1_640,   2008_1_700,   2008_1_710

To get the Clonefinder, all you need to be in ST-PI SP4. Then use the transaction /SDF/CD_CCA" -- Courtesy : Wiki in the above link.

 

 

So, i want to put that transaction to the maximum use and find all the SAP custom cloned programs which got effected due to upgrade.

 

Below is the step by step procedure which i followed to find all SAP custom cloned programs.

 

1.     Find all the custom packages in our system.

               a. Get all the "Z" packages from TVEDC table.

 

2.     Prioritize the packages based on their importance by speaking to the Functional consultant.

               a. Find out the number of objects per package and prioritize the packages based on the number of objects as well. (highest number of objects takes the first priority). TADIR table comes to rescue here. (Number of objects per package. Wrote a small program to do this task).

               b. We are interested only in programs and function modules here. Smartforms, scripts can be left. By the end of this step, we will have all the packages prioritized based on the number of objects it has.

 

3.      Now execute the transaction code /SDF/CD_CCA (Check the authorizations to execute it) with one package at a time or 10 based on the number of packages and load on each package as per convinience.

 

4.     From the output, copy the SAP standard programs column and feed them to TRDIR table where "NAME" = SAP standard programs and UDAT = Upgrade date range. So this effectively filters the objects and gives us only those standard programs which were effected due to upgrade.

 

5.     We have to change only those Custom cloned programs whose standard programs got effected due to the upgrade

 

6.     Version compare the standard program before upgrade and after upgrade and take a call if those changes are important for the custom program program as well.

 

p.s I have done the upgrade using Panaya Tool as well. Tool does the above steps for us and it sets the priority based on the usage levels of the program in production and the similarities. Even without tool also we can prioritize and find the similarities with the help of standard SAP itself.

 

Kindly pour in your inputs and your experiences with the clone programs. Anyways we all agree that less cloning and lesser maintenance


Debugging loop

$
0
0

Did you ever had to step into loop looking for 46-th row or looking for occurrence of some value?

Instead of painful record by record stepping trough loop, why not use breakpoints/watchpoints?

While debugging one can do this:

 

1. Open up Breakpoints/Watchpoints tab

Debugger1.PNG

2. Select breakpoint:

Debugger2.png

3. Set break point condition:

Debugger3.png

4. Continue debugging (F8):

Debugger4.png

5. This is it: debugger stops at 46-th record of the loop.

Debugger5.png

6. In case one need to stop at some specific value - at the step 3 specific condition is entered:

Debugger6.png

 

Small but useful debugging trick, I hope it will be helpful!

Manipulate Docx document with ABAP

$
0
0

There is a useful class CL_DOCX_DOCUMENT provided by SAP which could support read and write access to a word document with file extension ".docx".

This document gives a brief introduction about its usage and could be used as a starting point to build your own application which needs to manipulate word document via ABAP.

 

 

Office OpenXML

 

Starting with Microsoft Office2007, when you create a new word document, you will get a file with ".docx" file extension by default which follows the Office openXML format. You can find its detailed definition from wiki.

 

For example, I create a very simple word document which contains a header area, a paragraph with three lines as body, and a picture.


clipboard1.png

According to Office OpenXML protocal, after you change the file extension from ".docx" to ".zip", its icon changes to an archive file and thus could be opened via winrar. All information about my sample document are spreaded inside a series of xml files in the archive file ( plus media file like picture, music and video if the word document has such one).

 

The most efficient way to study is create a word document by yourself, change extension to zip and explore it.

clipboard2.png

 

Using CL_DOCX_DOCUMENT to read word document

 

I use the following sample code to explain how to use this class.

 

In order to avoid unnecessary local variable declaration, I use the new feature "inline declaration" available in release 740. If this version is not available for you, just replace them with old manual declaration for local variable.

 

DATA: lo_document TYPE REF TO cl_docx_document,
           lv_content  TYPE xstring.  PERFORM get_doc_binary USING 'C:\Users\i042416\Desktop\test.docx' CHANGING lv_content.  lo_document = cl_docx_document=>load_document( lv_content ).  CHECK lo_document IS NOT INITIAL.  DATA(lo_core_part) = lo_document->get_corepropertiespart( ).  DATA(lv_core_data) = lo_core_part->get_data( ).  DATA(lo_main_part) = lo_document->get_maindocumentpart( ).  DATA(lo_image_parts) = lo_main_part->get_imageparts( ).  DATA(lv_image_count) = lo_image_parts->get_count( ).  DO lv_image_count TIMES.    DATA(lo_image_part) = lo_image_parts->get_part( sy-index - 1 ).    DATA(lv_image_data) = lo_image_part->get_data( ).  ENDDO.  DATA(lo_header_parts) = lo_main_part->get_headerparts( ).  DATA(lv_header_count) = lo_header_parts->get_count( ).
DO lv_header_count TIMES.
DATA(lo_header_part) = lo_header_parts->get_part( sy-index - 1 ).
DATA(lv_header_data) = lo_header_part->get_data( ).
ENDDO.


Comments:


1. you can get a instance of word document via method cl_docx_document=>load_document. It is necessary to pass the document binary data with type xstring into this method. I don't list source code of subroutine get_doc_binary as it is not relevant. Just find it from attachment.

 

2. The system administrative data like author, creation and last modification date are stored in so called "Core property part", which could be fetched via document instance got in step1. Once you own the instance of Core property part, you can get its binary data via method get_data().

The returned data has xml format( so does all the left other kinds of parts in this document ) so it could be easily parsed via DOM or SAX parser.

clipboard3.png

3. from document instance we can get main part instance. Its binary data includes all the three body line texts with their font color:


clipboard4.png

clipboard5.png

4. The binary data of all pictures embedded in the word document could be retrieved via two steps. Firstly get the image part collection from main part instance and then loop each image part instance from the image collection. The get_part method accepts the index starting from 0. The way to read header block information is exactly the same.

 

Using CL_DOCX_DOCUMENT to change word document

 

See the nice document How to - Add Custom XML Parts to Microsoft Word using ABAP from Leon Limson.

 

You could also achieve the same requirement with the respective class below.

clipboard6.png

Playing around with Dynamic SQL's (for Starters)...!!!

$
0
0

Once in a while there comes a situation where we have to write Several Select queries to achieve similar functionality(with minor

change in the where condition. ) 

 

In such situations we simply start writing multiple select queries covering all the scenarios.

 

For Eg:query1 :-

 

 

SELECT * FROM vbap  into table t_vbap

where VBELN eq p_vbeln.

 

For Eg:query2 :-

 

SELECT * FROM vbap  into table t_vbap

where VBELN eq p_vbeln and posnr eq p_posnr.

 

What, We don't realise is that by making our select queries dynamic, we can minimize the effort as well as the number of code lines

 

Now the question is how do we do it. .

Well... I'll take a very basic example .....

 

 

 

PARAMETERS: p_vbeln type vbap-vbeln obligatory,

                           p_posnr  type vbap-posnr.   

 

DATA: lv_where TYPE string             "Declaring a string variable to manipulate our WHERE clause

 

 

INITIALIAZATION.

 

lv_where = ' VBELN EQ P_VBELN '.

 

 

START-OF-SELECTION.

 

 

 

 

 

if p_posnr is not initial.

     CONCATENATE  lv_where  'AND POSNR EQ P_POSNR' into lv_where.

endif.

 

SELECT * FROM VBAP into t_vbap WHERE (lv_where).   

 

Yipeeeee ...Our code is ready !!!!!

 

 

 

Regards,

Faiz

 

 

 

N Queens Algorithm - ABAP

$
0
0

Hi,

 

In this post I'll share with you the N Queens Algorithm brought to the ABAP language. I think this is a good exercise when it comes to refreshing our algorithmic capabilities.

 

*&---------------------------------------------------------------------*
 *& Report  Z_8QUEENS
 *&         Up to 10 x 10
 *&---------------------------------------------------------------------*
 *& Rubén Mircin
 *&---------------------------------------------------------------------*
 REPORT  Z_8QUEENS.
 TYPES: BEGIN OF gty_matrix,          1  TYPE c,          2  TYPE c,          3  TYPE c,          4  TYPE c,          5  TYPE c,          6  TYPE c,          7  TYPE c,          8  TYPE c,          9  TYPE c,          10 TYPE c,        END OF gty_matrix,        gty_t_matrix TYPE STANDARD TABLE OF gty_matrix INITIAL SIZE 8.
 DATA: gt_matrix TYPE gty_t_matrix,       gs_matrix TYPE gty_matrix,       gv_count  TYPE i VALUE 0,       gv_solut  TYPE i VALUE 0.
 SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
 PARAMETERS: p_number TYPE i OBLIGATORY DEFAULT 8.
 SELECTION-SCREEN END OF BLOCK b01.
 " Filling empty table
 START-OF-SELECTION.   DO p_number TIMES.     APPEND gs_matrix TO gt_matrix.   ENDDO.
 " Recursive Function   PERFORM fill_matrix USING gv_count 1 1 CHANGING gt_matrix.
 *&---------------------------------------------------------------------*
 *&      Form  FILL_MATRIX
 *----------------------------------------------------------------------*
 FORM fill_matrix  USING    p_count TYPE i                            p_i     TYPE i                            p_j     TYPE i                   CHANGING p_matrix TYPE gty_t_matrix.   DATA: lv_i      TYPE i,         lv_j      TYPE i,         lv_result TYPE c LENGTH 1,         lt_matrix TYPE gty_t_matrix,         lv_count  TYPE i,         lv_value  TYPE c.   lt_matrix[] = p_matrix[].   lv_count = p_count.   lv_i = p_i.   lv_j = p_j.   IF lv_count EQ p_number.     RETURN.   ENDIF.   WHILE lv_i LE p_number.     WHILE lv_j LE p_number.       CLEAR lv_result.       PERFORM check_position USING lv_i lv_j CHANGING lv_result lt_matrix.       IF lv_result NE 'X'.         MOVE 'X' TO lv_value.         PERFORM get_position USING lv_i lv_j 'U' CHANGING lv_value lt_matrix.         ADD 1 TO lv_count.         IF lv_count EQ p_number.           PERFORM show_matrix USING lt_matrix.         ELSE.           PERFORM fill_matrix USING lv_count lv_i lv_j CHANGING lt_matrix.         ENDIF.         lv_value = space.         PERFORM get_position USING lv_i lv_j 'U' CHANGING lv_value lt_matrix.         SUBTRACT 1 FROM lv_count.       ENDIF.       ADD 1 TO lv_j.     ENDWHILE.     ADD 1 TO lv_i.     lv_j = 1.   ENDWHILE.
 ENDFORM.                    " FILL_MATRIX
 *&---------------------------------------------------------------------*
 *&      Form  CHECK_POSITION
 *&---------------------------------------------------------------------*
 FORM check_position  USING value(p_i)  TYPE i                            value(p_j)  TYPE i                      CHANGING p_result TYPE c                               p_matrix TYPE gty_t_matrix.   DATA: lv_i TYPE i,         lv_j TYPE i.   lv_i = p_i.   lv_j = p_j.   PERFORM get_position USING lv_i lv_j 'R' CHANGING p_result p_matrix.   CHECK p_result NE 'X'.   PERFORM check_horizontal USING lv_i lv_j CHANGING p_result p_matrix.   CHECK p_result NE 'X'.   PERFORM check_vertical USING lv_i lv_j CHANGING p_result p_matrix.   CHECK p_result NE 'X'.   PERFORM check_diagonals USING lv_i lv_j CHANGING p_result p_matrix.
 ENDFORM.                    " CHECK_POSITION
 *&---------------------------------------------------------------------*
 *&      Form  GET_POSITION
 *&---------------------------------------------------------------------*
 FORM get_position  USING value(p_i)      TYPE i                          value(p_j)      TYPE i                          value(p_action) TYPE c                       CHANGING p_result  TYPE c                                p_matrix  TYPE gty_t_matrix.   FIELD-SYMBOLS: <fs_lmatrix> TYPE gty_matrix,                  <fs_lfield> TYPE any.   READ TABLE p_matrix ASSIGNING <fs_lmatrix> INDEX p_i.   ASSIGN COMPONENT p_j OF STRUCTURE <fs_lmatrix> TO <fs_lfield>.   CASE p_action.     WHEN 'U'.       <fs_lfield> = p_result.     WHEN 'R'.       p_result = <fs_lfield>.     WHEN OTHERS.   ENDCASE.
 ENDFORM.                    " GET_POSITION
 *&---------------------------------------------------------------------*
 *&      Form  CHECK_HORIZONTAL
 *&---------------------------------------------------------------------*
 FORM check_horizontal  USING value(p_i)      TYPE i                              value(p_j)      TYPE i                           CHANGING p_result  TYPE c                                    p_matrix  TYPE gty_t_matrix.   DATA: lv_j TYPE i,         ls_matrix TYPE gty_matrix.   FIELD-SYMBOLS <fs> TYPE c.   lv_j = 1.   READ TABLE p_matrix INTO ls_matrix INDEX p_i.   WHILE lv_j LE p_number.     ASSIGN COMPONENT lv_j OF STRUCTURE ls_matrix TO <fs>.     IF <fs> EQ 'X'.       p_result = 'X'.       RETURN.     ENDIF.     ADD 1 TO lv_j.   ENDWHILE.
 ENDFORM.                    " CHECK_HORIZONTAL
 *&---------------------------------------------------------------------*
 *&      Form  CHECK_VERTICAL
 *&---------------------------------------------------------------------*
 FORM check_vertical  USING value(p_i)      TYPE i                            value(p_j)      TYPE i                         CHANGING p_result  TYPE c                                  p_matrix  TYPE gty_t_matrix.   DATA: lv_i TYPE i,         ls_matrix TYPE gty_matrix.   FIELD-SYMBOLS <fs> TYPE c.   lv_i = 1.   WHILE lv_i LE p_number.     READ TABLE p_matrix INTO ls_matrix INDEX lv_i.     ASSIGN COMPONENT p_j OF STRUCTURE ls_matrix TO <fs>.     IF <fs> EQ 'X'.       p_result = 'X'.       RETURN.     ENDIF.     ADD 1 TO lv_i.   ENDWHILE.
 ENDFORM.                    " CHECK_VERTICAL
 *&---------------------------------------------------------------------*
 *&      Form  CHECK_DIAGONALS
 *&---------------------------------------------------------------------*
 FORM check_diagonals  USING value(p_i)      TYPE i                             value(p_j)      TYPE i                          CHANGING p_result  TYPE c                                   p_matrix  TYPE gty_t_matrix.   DATA: lv_dx TYPE i,         lv_dy TYPE i.
 * I++ J++ (Up Right)   lv_dx = 1.   lv_dy = 1.   PERFORM check_diagonal USING p_i p_j lv_dx lv_dy CHANGING p_result p_matrix.   CHECK p_result NE 'X'.
 * I-- J-- (Left Down)   lv_dx = -1.   lv_dy = -1.   PERFORM check_diagonal USING p_i p_j lv_dx lv_dy CHANGING p_result p_matrix.   CHECK p_result NE 'X'.
 * I++ J-- (Right Down)   lv_dx = 1.   lv_dy = -1.   PERFORM check_diagonal USING p_i p_j lv_dx lv_dy CHANGING p_result p_matrix.   CHECK p_result NE 'X'.
 * I-- J++ (Left Up)   lv_dx = -1.   lv_dy = 1.   PERFORM check_diagonal USING p_i p_j lv_dx lv_dy CHANGING p_result p_matrix.   CHECK p_result NE 'X'.
 ENDFORM.                    " CHECK_DIAGONALS
 *&---------------------------------------------------------------------*
 *&      Form  CHECK_DIAGONAL
 *&---------------------------------------------------------------------*
 FORM check_diagonal  USING value(p_i)      TYPE i                             value(p_j)      TYPE i                             value(p_dx)      TYPE i                             value(p_dy)      TYPE i                          CHANGING p_result  TYPE c                                   p_matrix  TYPE gty_t_matrix.   DATA: lv_i TYPE i,         lv_j TYPE i,         ls_matrix TYPE gty_matrix.   FIELD-SYMBOLS <fs> TYPE c.   lv_i = p_i.   lv_j = p_j.   WHILE 1 EQ 1.     ADD: p_dx TO lv_i, p_dy TO lv_j.     IF p_dx EQ 1.       IF lv_i GT p_number. EXIT. ENDIF.     ELSE.       IF lv_i LT 1. EXIT. ENDIF.     ENDIF.     IF p_dy EQ 1.       IF lv_j GT p_number. EXIT. ENDIF.     ELSE.       IF lv_j LT 1. EXIT. ENDIF.     ENDIF.     READ TABLE p_matrix INTO ls_matrix INDEX lv_i.     ASSIGN COMPONENT lv_j OF STRUCTURE ls_matrix TO <fs>.     IF <fs> EQ 'X'.       p_result = 'X'.       RETURN.     ENDIF.   ENDWHILE.
 ENDFORM.                    " CHECK_DIAGONAL
 *&---------------------------------------------------------------------*
 *&      Form  SHOW_MATRIX
 *----------------------------------------------------------------------*
 FORM show_matrix USING p_matrix TYPE gty_t_matrix.   DATA: lt_matrix TYPE gty_t_matrix,         lv_j      TYPE i VALUE 1,         lv_colum  TYPE string VALUE '-'.   FIELD-SYMBOLS: <fs_matrix> TYPE gty_matrix,                  <fs_field>  TYPE c.
 *  lt_matrix[] = p_matrix.
 *  REPLACE ALL OCCURRENCES OF 'X' IN TABLE lt_matrix WITH '♕' IGNORING CASE IN CHARACTER MODE.
   ADD 1 TO gv_solut.   WRITE:/ 'Solution: ', gv_solut.   DO p_number TIMES.     CONCATENATE lv_colum '----' INTO lv_colum.   ENDDO.
 *  LOOP AT lt_matrix ASSIGNING <fs_matrix>.   LOOP AT p_matrix ASSIGNING <fs_matrix>.     IF sy-tabix EQ 1.       WRITE:/ lv_colum.     ENDIF.     WRITE:/ '|'.     DO p_number TIMES.       ASSIGN COMPONENT lv_j OF STRUCTURE <fs_matrix> TO <fs_field>.       IF <fs_field> EQ space.         WRITE: <fs_field> ,'|'.       ELSE.         WRITE: <fs_field> COLOR 2 HOTSPOT ON,'|'.       ENDIF.       ADD 1 TO lv_j.     ENDDO.     lv_j = 1.     WRITE: / lv_colum.   ENDLOOP.   SKIP 1.
ENDFORM.                    " SHOW_MATRIX

 

Kind Regards.

Rubén

Create Custom Tab at Header in Purchase Requistion

$
0
0

As we all know we can create a custom tab at item level in Purchase Requistion and wonder is it possible to create custom tab in header lvel of Purchase Requistion ??

 

                       I have tried a lot by searching all the Function exists, Sreen exists and BADI but unable to find any enahcement . I even searched SAP forums but could not find any positive approach.At last I have found myself small information which lead to me to discover custom tab in Header level in Purchase Requistion.

              6-3-2014 3-58-41 PM.jpg

We can clealry see that CUSTOM TAB which we create '0111' in Program SAPLXM02  is register here. So there may possibilty for custom tab in header level also.With this intennt I tried hard to explore, than I FM - MEGUI_BUILD_REQ_HEADER_PLUGIN which enables custom tab at header level if we can create an implicit enahncment in it as shown below.

6-6-2014 12-38-47 AM.jpg

 

**--Declare a custom header view with ref to local class  LCL_CUST_HEADER_VIEW_MM of function pool MEGUI.

DATA: CUST_HEADER_VIEW   TYPE REF TO LCL_CUST_HEADER_VIEW_MM.


  CREATE OBJECT CUST_HEADER_VIEW
                EXPORTING im_dynpro         = '1227'               "Custom tab provided by SAP
                          im_prog                         = megui               "Function Group
                         im_foreign_prog            = 'SAPLXM02'    "Main Program to create Custom Screen
                         im_foreign_dynpro        = '0999'.              "Custom screen ->Can have any no


  CALL METHOD CUST_HEADER_VIEW->set_label( 'Custom Tab - Header ').    "Set Label as shown on screen
  CALL METHOD CUST_HEADER_VIEW->set_name( 'Cust Header Tab' ).          "Set a name to refer
  CALL METHOD CUST_HEADER_VIEW->set_struct_name( ).                             "Get default structure


  CALL METHOD header_view->add
    EXPORTING
      im_screen_view = CUST_HEADER_VIEW
      im_position    = 4.


  SET HANDLER CUST_HEADER_VIEW->if_observer_mm~handle_subject_changed
              FOR header_view.

  SET HANDLER header_view->if_observer_mm~handle_subject_changed FOR
              CUST_HEADER_VIEW.

 

                 Now, we need to create a screen in the program SAPLXM02, I shall leave this to you guys. We need to create implicit enhancement to method 'TRANSPORT_FROM_MODEL'  of class LCL_CUST_HEADER_VIEW_MM  to view the custom tab at header level.

6-6-2014 12-55-09 AM.jpg              

  6-6-2014 12-58-33 AM.jpg

 

DATA: L1_HEADER        TYPE REF TO IF_PURCHASE_REQUISITION.
        
    FOREIGN_APPLICATION_OK = MMPUR_NO.
    MMPUR_DYNAMIC_CAST L1_HEADER MY_MODEL.
    CHECK NOT L1_HEADER IS INITIAL.
    FOREIGN_APPLICATION_OK = MMPUR_YES.
 
**---Export values to PBO of Custom Screen 999 of SAPLXM02- to use in PBO

      EXPORT L1_HEADER from L1_HEADER to MEMORY id 'REq@Header_value'.
        
    EXIT."Over write Standard Implementation -THIS IS MANDATORY

 

            Now, we are all set to call transaction ME51N to view Custom tab in Header level in Purchase Requisition

         6-6-2014 1-05-32 AM.jpg

             [ Now the data part is left to you, how to handle data at PAI , PBO and fetch from Table and Save into Table .......Hope this helps at least a bit]

 

DISCLAIMER: APOLOGIZE IF MY INFORMATION TOO OLD TO SHARE..!!

Create FI Substitutions using GGB1 (Substitution Maintenance)

$
0
0

Substitution in SAP FI is done to insert/infuse values into existing set of value(s) in fields. There are many cases where functional consultant don't want to clutter up things using User-exits and SAP Enhancements. This is one of the best tool/method provided for keeping all the things/coding tidy as far as simple Substitutions are concerned. For complex Substitution, of-course User-exit (within the Substitution) needs to be written down as per requirements.

 

In this step-by-step document, we will traverse through a simple Substitution case involving Customer User-Exit showing the flexibility of SAP Substitution.

 

Our Example Case: Substitute 'Additional asset description' field (ANLA-TXA50) value with 15 digit code maintained in Key word for G/L accounts in G/L account master.

 

substitution_main.jpg

 

 

1. Execute Tcode GGB1 and define the Substitution. Insert step in it.

 

substitution_01.jpg

 

Here you can define the prerequisite based upon your requirements. In our case lets say we want it in all cases so we left it as blank.

substitution_02.jpg

 

In Substitution step, define the Substitution based on Exits. We have to define our custom Exit in EXIT-Formpool provided by SAP or we can copy the standard and create our own Module Pool for the same. In our case, we have copied  FAGGBS0 to  ZFAGGBS0 and defined the same in view V_T80D with Application Area as GBLS (Val/sub:Exits for substitution) and Ex.prog. as ZFAGGBS0.

 

substitution_03.jpg

 

 

substitution_04.jpg

2. In the Module pool, define the exit name in the header in FORM GET_EXIT_TITLES.

 

substitution_05.jpg

 

and down below in code, we define our code based on our logic as follows:

 

substitution_06.jpg

 

3. In our last step, we have to activate this Substitution using the TCode OACS (FI-AA View maint. substitutions).

 

substitution_07.jpg

 

This is the ideal case where we have taken the field which is 'Active' for Substitution.

 

There are times when we need to use the substitutions for particular fields but they are unavailable in Tcode GGB1. This requires a small effort to include the requisite field for Substitution.

 

1. Check if the field that needs to be substituted is already present in Tcode GGB1 or not.

2. If it is not present, go to SM30 -> table VWTYGB01. Click Maintain.

3. Uncheck the “Exclude” checkbox for the requisite field.

4. Run the program RGUGBR00 via SE38 and click execute.

5. The field will get added to the Substitution Rules.

 

Hope this helps you in applying Substitution successfully in SAP.

How to place an SE78 image on an Adobe Form

$
0
0

The following five steps show how to place an SE78 graphic on an Adobe Form.

 

In this example, we will add an existing color logo named Z_LOGO to an existing Adobe form,
ZRUOTC_SERVSTAR_PDF. First, make sure the logo exists in SE78 as a bitmap image and that
the Adobe form and interface exist as well.


(1) Go to transaction SE78 and ascertain Z_LOGO exists by following this path:
    Form Graphics->Stored on Document Server->GRAPHICS General Graphics->BMAP Bitmap Images.
    Do a print preview to see the graphic. 
  
  
(2) Go to transaction SFP. Select the Interface radio button and click the Change icon.

    Under the Global Definitions folder double click into Global Data and add these fields.
   
    Variable name     Type Assignment     Type Name                         Default Value
    V_FIELD                 TYPE                       XSTRING
    V_BTYPE               TYPE                       TDBTYPE                              'BCOL'
    V_ID                       TYPE                       TDIDGR                                 'BMAP'
    V_OBJECT            TYPE                       TDOBJECTGR                      'GRAPHICS'
    V_NAME                TYPE                       STXBITMAPS-TDNAME       'Z_LOGO'
    G_LOGO               TYPE                        XSTRING

 

    Do a syntax check.

 

(3) Under the Initialization folder, double click into the Code Initialization area.

    Create the following logic.
 
   * Call method get_bds_graphic_as_bmp to retrieve z_logo. Note that v_field and g_logo
   * MUST be typed as XSTRING NOT string or the conversion of the form from SE78 will
   * not work and the logo will NOT display on the Adobe form. On the layout tab of the
   * Adobe form, bind z_logo to the graphics node created here in the Interface, NOT
   * directly to g_logo. Adobe sees g_logo as a text field.
     CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
       EXPORTING
         p_object           = v_object      " 'GRAPHICS'
         p_name            = v_name      " Name of the SE78 logo inside Quotes
         p_id                  = v_id            " 'BMAP'
         p_btype            = v_btype      " 'BCOL' for color, 'BMON' for Black & White
     RECEIVING
        p_bmp             = v_field        " v_field and g_logo must be typed xstring
     EXCEPTIONS
        not_found        = 1
        internal_error   = 2
        OTHERS         = 3.
   g_logo = v_field.                       " g_logo and v_field must be typed xstring

 

   Do a syntax check, save, and back out of the Interface.

 

(4) Select the Adobe Form radio button and click the Change Icon.

    Go to the Context tab.
    Expand the Global Data folder. You should see the 6 fields created in the Interface.

    Under the Context bar on the upper right window, right click on the top folder.
    Choose Create, Graphic and give it a name.

    Under the Global Data folder on the upper left window locate the G_LOGO field.
    Drag and drop G_LOGO on top of your new Graphics Node.

    Under Properties at the bottom right window, change the Graphic Type Value.
    It defaults to 'Graphic Reference'. Change it to 'Graphic Content'.
    Enter G_LOGO as the Graphic Content field.
    Enter 'IMAGE/BMP' with the quotes as the MIME Type.
 
(5) Go to the Layout Tab of the Adobe form.
   Expand the standard palette object library and choose an Image Field.
   Drag and drop the Image field to the location on the form where you want the logo displayed.

   Under the Field tab make sure the URL field is blank because this is not a static logo.
   Check the Embed Image Data box. However, it seems to work checked or unchecked.
   Choose Scale Image Proportionately.
   Under the Binding Tab, bind the image field to the Graphic Node, not to the G_LOGO field.

 

   Do a syntax check on the interface and form. Save and activate. 



LSMW – Task List Creation with 5 level input file using Batch Input

$
0
0

Requirement: 

Creation of Task List using LSMW Batch Input with 1 input file having 5 level Structure data.

 

Mapping Template:

5 Structures:

1.jpg

Fields in the structures:

2.jpg

Note:     1) All these 5 rows generate 1 Task list.  

2) There can contain multiple Operations (level2) for each Header (Level1) in the input file.

3) There can be multiple Text Lines (Level3), Components (Level4), and Packages (Level5) for   

each Operation (Level2).

 

Input File Format:

3.jpg

The first Column is the Unique Identifier, which we need to maintain at the source field level for correct mapping.



LSMW:

Steps Involved:

4.jpg

Step1:  Maintain Object Attributes

 

We have Batch Input for the Task List Creation in the LSMW.

Data Transfer Object:           0490

Data Transfer Method:        B (Batch Input)

5.jpg

Step 2: Maintain Source Structures

 

Maintain Source Structures as per the Hierarchy.

Create a Header File Structure. Add Operation as the child Node (Next Level) to Header.

Add Long Text, Components, Packages structures as the child node (Next level) to Operations.

But all these three at same level

 

6.jpg

 

Step3: Maintain Source Fields

 

Maintain a Unique Identifier “RECORDNAME” in each structure.

 

7.jpg

 

Double Click the RECORDNAME Field and fill the identifying Field Content with some Unique Value.    

8.jpg

Similarly, do this for all the Identifying fields in each structure. The same can be screen in the screenshots.

9.jpg

Step4: Maintain Structure Relations

 

Map the structures respectively.

 

10.jpg

Step5: Maintain Field Mapping and Conversion Rules

Go to Menu Bar -> Extras -> Auto Field Mappings.

11.jpg

This will map the fields in our Source structures to the corresponding fields the Target Structures.

 

12.jpg

13.jpg

Similarly, all the fields will be mapped accordingly. It will be better to cross check.

 

Step6:Maintain Fixed Values, Translations, User-Defined Routines

 

User Defined Routines or Values can be maintained at this step.

 

Step7:Specify Files

 

At this step, specify the input file present at the Presentation Server.

14.jpg

Step8:Assign Files

 

Assign the input file to each structure applicable as shown below

15.jpg

As we have single input file, assign the same to all the structures applicable.

 

Step9: Read Data

 

At this Step, the data in the input file will be read and stored in the Structures.

16.jpg


Step10: Display Read Data

17.jpg

 

Step11:Convert Data

 

The data read from the input file, will be converted as the rules we provide in the field mapping stage.

Ex: Here, Conversion Exit was used was for Equipment Number.  This conversion will be executed at this stage.

 

18.jpg

 

Step12: Display Converted Data

 

The data converted, can be seen at this step.

 

19.jpg

Step13: Create Batch Input Session

 

This step will create the Batch Session. We need to provide the Session Name at this step.

20.jpg

 

Provide the Session Name. Delete the Deletion indicator, if you want to keep the session even after processing.

21.jpg

 

Step14: Run Batch Input Session

This will take you to SM35.  You can process the session according to your requirement.

 


Hope this might be helpful...!



Thanks

Prasanth Reddy.

Development dependencies translator with Transport

$
0
0
tools.jpg

When developing for Multilingual clients normally translations are required. Even using standard transactions or reports this is a time consuming and boring task.


I build this tool to accelerate and improve translations quality. You can easily copy texts from source to target languages, import/export to excel file and prepare a transport request including only language-specific components.

Standard features:

  • Attached to each ABAP object development transaction you can run local translations by language;
  • Using existent standard transactions and reports (SE63, SLXT, LXE_MASTER, etc) to mass translate objects and transport can be complex and dependencies are not checked.

 

If you are looking for a user friendly and simple program for translations please implement the tool bellow.

How to implement:

  • In SE38 create a executable report in your SAP development system with name ZNM_TRANSLATOR and description Development Translation and Transport;
  • Copy past code bellow and activate the program;
  • Create/Fill corresponding Text Symbols and Selection Texts. Please check the meaning at top comments of the program;
  • Go to transaction SE41, select button copy status Untitled.png and fill popup. After copy you can delete function codes not needed.

Untitled.png

  • Edit status to add the following customer functions codes:
    • DOWN with text Download Template and icon ICON_SAVE_AS_TEMPLATE;
    • UP with text Upload Template and icon ICON_IMPORT;
    • COPY with text Copy source language to targets and icon ICON_SYSTEM_COPY;
    • TR with text Transport translations and icon ICON_IMPORT_TRANSPORT_REQUEST.

Untitled.png

 

If you are not able to activate the program because of nonexistent standard objects please downgrade for earlier SAP versions. If you need help on it, please kept me informed.


Copy past the code bellow or download the attached file:


REPORT znm_translator MESSAGE-ID 00.
*----------------------------------------------------------------------*
* Created by NM for Object Dependencies translation and Transport
*----------------------------------------------------------------------*
* Text Symbols
* B01  Object selection
* B02  Translation options
* C01  Obj. Desc.
* C02  Source
* C03  Targets
* C04  Trans. St.
* C05  Proc. St.
* C06  Check St.
* D01  Please select target language:
* D02  Edit Translation
* EX1  Executed with success
* EX2  Executed with errors
* F01  Translations
* F02  Automatic translations. Continue?
* G01  Upload Template
* G02  Download Template
* M01  Please fill all required fields
* M02  Error opening file
* M03  Objects not found
* M04  No objects selected
* M05  Transport not allowed for multiple targets
* M06  No dependecies found
* M07  Objects added to request
* M08  Overwrite existent translations activated
* M09  Transport canceled
* M10  Request canceled, at least one object $TEMP detected
* M11  File not valid
* M12  File source language not valid
* M13  File target languages not valid
* P01  Adding object
* P02  Checking Dependecies
* P03  Checking Translations
* P04  Display objects
* PB1  % Complete
* T01  Object
* T02  dependecies and translations
*
* Selection Texts
* P_OBJECT Object Type
* P_OBJ_N  Object Name
* P_OW Overwrite translations
* P_PGMID Program ID
* P_SLANG Source Language
* SO_TLANG Target Languages
*
* Standard Status GUI function codes: &ALL, &SAL, &OUP, &ODN, &ILT, %PC, &OL0, &OAD and &AVE
* Status GUI function code: DOWN Download Template, UP Upload Template, COPY Copy source language to targets and TR Transport translations
*
*--------------------------------------------------------- GLOBAL DATA *
TABLES t002.                  "Language Keys
TYPE-POOLS: abap, icon, ole2. "Only for old versions
*----------------------------------------------------------- Constants *
CONSTANTS:   gc_r3tr          TYPE pgmid        VALUE 'R3TR',    "Main object   gc_temp          TYPE developclass VALUE '$TMP',    "Local development class   gc_excel_ext     TYPE string       VALUE 'XLSX',    "Excel file extention   gc_ieq(3)        TYPE c            VALUE 'IEQ',     "Ranges   gc_pgmid(5)      TYPE c            VALUE 'PGMID',   "Fields names   gc_object(6)     TYPE c            VALUE 'OBJECT',   gc_lxe_object(3) TYPE c            VALUE 'LXE',   gc_textkey(8)    TYPE c            VALUE 'TEXTPAIR'.
*---------------------------------------------------------- Structures *
*---------- Objects ----------*
TYPES:   BEGIN OF gty_objects,     status   TYPE icon_d,       "Check status     pgmid    TYPE pgmid,        "Program ID in Requests and Tasks     object   TYPE trobjtype,    "Object Type     obj_name TYPE sobj_name,    "Object Name in Object Directory     obj_desc TYPE ddtext,       "Object Explanatory short text     slang    TYPE spras,        "Source Language     tlangs   TYPE string,       "Target Languages     stattrn  TYPE icon_d,       "Initial Translation status of an Object     statproc TYPE icon_d,       "Process Translation status of an Object     devclass TYPE developclass, "Development Package     target   TYPE tr_target,    "Transport Target of Request   END OF gty_objects.
*---------- LXE Object Lists ----------*
TYPES:   BEGIN OF gty_colob,     pgmid    TYPE pgmid,        "Program ID in Requests and Tasks     object   TYPE trobjtype,    "Object Type     obj_name TYPE sobj_name.    "Object Name in Object Directory         INCLUDE TYPE lxe_colob. "Object Lists
TYPES:   END OF gty_colob.
*---------- Languages Informations ----------*
TYPES:   BEGIN OF gty_languages,     r3_lang(2) TYPE c,          "R3 Language (Char 2)     laiso      TYPE laiso,      "Language according to ISO 639     o_language TYPE lxeisolang, "Translation Language     text       TYPE sptxt,      "Name of Language   END OF gty_languages.
SET EXTENDED CHECK OFF.
DATA:   gt_objects    TYPE TABLE OF gty_objects,    "Objects to transport   gt_objs_desc  TYPE TABLE OF ko100,          "Objects prograns IDs   gt_objs_colob TYPE TABLE OF gty_colob,      "LXE Object Lists   gt_languages  TYPE TABLE OF gty_languages.  "Target Languages Informations
*----------------------------------------------------------- Variables *
DATA:   gv_percent  TYPE i,       "Progress bar percentage   gv_tlangs   TYPE string,  "Target Languages   gv_msg_text TYPE string.  "All Global Exceptions Text
*------------------------------------------------------------- Objects *
DATA:    go_objects TYPE REF TO cl_salv_table,  "Objects ALV    go_exp     TYPE REF TO cx_root.        "Abstract Superclass for All Global Exceptions
SET EXTENDED CHECK ON.
*-------------------------------------- CLASS HANDLE EVENTS DEFINITION *
CLASS lcl_handle_events DEFINITION FINAL.   PUBLIC SECTION.     METHODS:       on_user_command FOR EVENT added_function OF cl_salv_events         IMPORTING e_salv_function,       on_double_click FOR EVENT double_click OF cl_salv_events_table         IMPORTING row column.                               "#EC NEEDED
ENDCLASS.                    "lcl_handle_events DEFINITION
*---------------------------------------------------- SELECTION SCREEN *
*---------------------------------------------------- Object selection *
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:   p_pgmid  TYPE pgmid DEFAULT gc_r3tr,  "Program ID in Requests and Tasks   p_object TYPE trobjtype,              "Object Type   p_obj_n  TYPE sobj_name.              "Object Name in Object Directory
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b01.
*-------------------------------------------------- Translation options *
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
SELECTION-SCREEN SKIP 1.
PARAMETERS p_slang TYPE spras DEFAULT 'EN'.           "Source Language
SELECT-OPTIONS so_tlang FOR t002-spras NO INTERVALS.  "Target Languages
SELECTION-SCREEN SKIP 1.
PARAMETERS p_ow AS CHECKBOX.  "Overwrite existent translations
SELECTION-SCREEN END OF BLOCK b02.
*--------------------------------------------- SELECTION SCREEN EVENTS *
*------------------------------------------------------- Program ID F4 *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pgmid.   PERFORM pgmid_f4.
*------------------------------------------------------ Object Type F4 *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_object.   PERFORM object_f4.
*------------------------------------------------------ Object Name F4 *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_obj_n.   PERFORM object_name_f4.
*----------------------------------------- Selection Screen Events PAI *
AT SELECTION-SCREEN.   PERFORM screen_pai.
*------------------------------------------------------- REPORT EVENTS *
*----------------------------------------------- Initialization events *
INITIALIZATION.   PERFORM load_of_program.
*---------------------------------------------------- Executing events *
START-OF-SELECTION.   PERFORM run_checks.
END-OF-SELECTION.   PERFORM display_objects.
*--------------------------------------------------------------- FORMS *
*------------------------------------------------ Form LOAD_OF_PROGRAM *
FORM load_of_program.   DATA:     lt_restrict  TYPE sscr_restrict,  "Select Options Restrict     lt_opt_list  TYPE sscr_opt_list,     lt_associate TYPE sscr_***.       "selection screen object
*---------- Fill Program IDs ----------*   CALL FUNCTION 'TR_OBJECT_TABLE'     TABLES       wt_object_text = gt_objs_desc.
*---------- SC restrict SOs ----------*   lt_opt_list-name = gc_ieq+1(2).   lt_opt_list-options-eq = abap_true.   APPEND lt_opt_list TO lt_restrict-opt_list_tab.   lt_associate-kind    = 'S'.   lt_associate-name    = 'SO_TLANG'.   lt_associate-sg_main = gc_ieq(1).   lt_associate-sg_addy = space.   lt_associate-op_main = gc_ieq+1(2).   lt_associate-op_addy = gc_ieq+1(2).   APPEND lt_associate TO lt_restrict-***_tab.   CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'     EXPORTING       restriction            = lt_restrict     EXCEPTIONS       too_late               = 1       repeated               = 2       selopt_without_options = 3       selopt_without_signs   = 4       invalid_sign           = 5       empty_option_list      = 6       invalid_kind           = 7       repeated_kind_a        = 8       OTHERS                 = 9.   IF sy-subrc IS NOT INITIAL.     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.   ENDIF.
ENDFORM.                    " LOAD_OF_PROGRAM
*------------------------------------------------------- Form PGMID_F4 *
FORM pgmid_f4 .   DATA lt_pgmids TYPE TABLE OF ko101.  "Program IDs with Description
*---------- Read PGMID ----------*   CALL FUNCTION 'TR_PGMID_TABLE'     TABLES       wt_pgmid_text = lt_pgmids.
*---------- Set PGMID F4 ----------*   CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'              "#EC FB_RC     EXPORTING       retfield        = 'PGMID'       dynpprog        = sy-cprog       value_org       = 'S'       dynpnr          = '1000'       dynprofield     = 'TRE071X-PGMID'     TABLES       value_tab       = lt_pgmids     EXCEPTIONS       parameter_error = 1       no_values_found = 2       OTHERS          = 3.
ENDFORM.                    " PGMID_F4
*------------------------------------------------------ Form OBJECT_F4 *
FORM object_f4.   DATA:     lt_shlp          TYPE shlp_descr,               "Description of Search Help     lt_return_values TYPE TABLE OF ddshretval,      "Interface Structure Search Help     ls_return_values LIKE LINE OF lt_return_values,     lv_rc            TYPE sysubrc.                  "Return Value of ABAP Statements   FIELD-SYMBOLS <interface> TYPE ddshiface.         "Interface description of a F4 help method
*---------- Get search help ----------*   CALL FUNCTION 'F4IF_GET_SHLP_DESCR'     EXPORTING       shlpname = 'SCTSOBJECT'     IMPORTING       shlp     = lt_shlp.
*---------- Fill search help ----------*   LOOP AT lt_shlp-interface ASSIGNING <interface>.     IF <interface>-shlpfield = gc_object.       <interface>-valfield = abap_true.       <interface>-value    = p_object.     ENDIF.     IF <interface>-shlpfield = gc_pgmid.       <interface>-valfield = abap_true.       <interface>-value    = p_pgmid.     ENDIF.   ENDLOOP.
*---------- Call search help ----------*   CALL FUNCTION 'F4IF_START_VALUE_REQUEST'     EXPORTING       shlp          = lt_shlp     IMPORTING       rc            = lv_rc     TABLES       return_values = lt_return_values.
*---------- Set search help return ----------*   IF lv_rc IS INITIAL.     READ TABLE lt_return_values INTO ls_return_values WITH KEY fieldname = gc_object.     IF sy-subrc IS INITIAL.       p_object = ls_return_values-fieldval.     ENDIF.     READ TABLE lt_return_values INTO ls_return_values WITH KEY fieldname = gc_pgmid.     IF sy-subrc IS INITIAL.       p_pgmid = ls_return_values-fieldval.     ENDIF.   ENDIF.
ENDFORM." OBJECT_F4
*------------------------------------------------- Form OBJECT_NAME_F4 *
FORM object_name_f4.   DATA lv_object_type TYPE seu_obj.  "Object type
*---------- Get objects repository information ----------*   lv_object_type = p_object.   CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'                 "#EC FB_RC     EXPORTING       object_type          = lv_object_type       object_name          = p_obj_n     IMPORTING       object_name_selected = p_obj_n     EXCEPTIONS       cancel               = 1       wrong_type           = 2       OTHERS               = 3.
ENDFORM.                    " OBJECT_NAME_F4
*----------------------------------------------------- Form SCREEN_PAI *
FORM screen_pai .   DATA:     ls_env_dummy TYPE senvi,                "Object in Development Environment     ls_language  LIKE LINE OF gt_languages, "Languages Informations     ls_tlang     LIKE LINE OF so_tlang.     "Target Languages
*---------- Execute ----------*   IF sy-ucomm = 'ONLI'.     TRY.
*---------- Check required data ----------*         IF p_pgmid IS INITIAL OR p_object IS INITIAL OR p_obj_n IS INITIAL OR p_slang IS INITIAL OR           so_tlang[] IS INITIAL.           MESSAGE e398 WITH text-m01 space space space DISPLAY LIKE 'W'.  "Please fill all required fields         ENDIF.
*---------- Check and Read languages informations ----------*         ls_tlang     = gc_ieq.         ls_tlang-low = p_slang.         APPEND ls_tlang TO so_tlang.         REFRESH gt_languages.         CLEAR gv_tlangs.         LOOP AT so_tlang INTO ls_tlang WHERE low IS NOT INITIAL.           CALL FUNCTION 'LXE_T002_CHECK_LANGUAGE' "#EC FB_RC  "#EC CI_SUBRC             EXPORTING               r3_lang            = ls_tlang-low             IMPORTING               text               = ls_language-text       "Name of Language               o_language         = ls_language-o_language "Translation Language             EXCEPTIONS               language_not_in_cp = 1               unknown            = 2               OTHERS             = 3.           CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT'             EXPORTING               input  = ls_tlang-low             IMPORTING               output = ls_language-r3_lang.           ls_language-laiso = ls_tlang-low. "Language according to ISO 639           IF ls_tlang-low <> p_slang.             IF gv_tlangs IS INITIAL.               gv_tlangs = ls_language-r3_lang.             ELSE.               CONCATENATE gv_tlangs ls_language-r3_lang INTO gv_tlangs SEPARATED BY space.             ENDIF.           ENDIF.           APPEND ls_language TO gt_languages.           CLEAR ls_language.         ENDLOOP.         DELETE so_tlang WHERE low = p_slang.
*---------- Add first object ----------*         PERFORM progress_bar USING text-p01 '10'. "Adding object         PERFORM check_add_object USING p_pgmid p_object p_obj_n ls_env_dummy.         IF gt_objects IS INITIAL.           MESSAGE e398 WITH text-m03 space space space DISPLAY LIKE 'W'.  "Object not found         ENDIF.         IF p_ow IS NOT INITIAL.           MESSAGE w398 WITH text-m08 space space space. "Overwrite existent translations activated         ENDIF.       CATCH cx_root INTO go_exp.                         "#EC CATCH_ALL         gv_msg_text = go_exp->get_text( ).         MESSAGE s398 WITH gv_msg_text space space space DISPLAY LIKE 'E'. "Critical error     ENDTRY.   ENDIF.
ENDFORM.                    " SCREEN_PAI
*--------------------------------------------------- Form PROGRESS_BAR *
FORM progress_bar USING i_value TYPE itex132 i_tabix TYPE i.   DATA:     lv_text(40),     lv_percentage TYPE p,     lv_percent_char(3).   lv_percentage = ( i_tabix / 100 ) * 100.   lv_percent_char = lv_percentage.   SHIFT lv_percent_char LEFT DELETING LEADING space.   CONCATENATE i_value '...' INTO i_value.   CONCATENATE i_value lv_percent_char text-pb1 INTO lv_text SEPARATED BY space.   IF lv_percentage GT gv_percent OR i_tabix = 1.     CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'       EXPORTING         percentage = lv_percentage         text       = lv_text.     gv_percent = lv_percentage.   ENDIF.
ENDFORM.                    " PROGRESS_BAR
*------------------------------------------------ Form DISPLAY_OBJECTS *
FORM display_objects.   DATA:     lr_events        TYPE REF TO cl_salv_events_table,      "ALV Events     lr_display       TYPE REF TO cl_salv_display_settings,  "ALV Output Appearance     lr_columns       TYPE REF TO cl_salv_columns_table,     "ALV Columns     lr_column        TYPE REF TO cl_salv_column_table,     lr_selections    TYPE REF TO cl_salv_selections,        "ALV Selections     lr_layout        TYPE REF TO cl_salv_layout,            "ALV Layout     lo_event_handler TYPE REF TO lcl_handle_events.         "ALV Events Handler   DATA:     lt_column_ref TYPE salv_t_column_ref, "Columns of ALV List     ls_column_ref TYPE salv_s_column_ref,     ls_key        TYPE salv_s_layout_key. "Layout Key   DATA:     lv_title   TYPE lvc_title,  "ALV title     lv_lines   TYPE i,          "Number of objects     lv_lines_c TYPE string.   PERFORM progress_bar USING text-p04 '90'. "Display objects   IF go_objects IS NOT BOUND. "Create ALV     TRY.         IF lines( gt_objects ) = 1.           MESSAGE s398 WITH text-m06 space space space DISPLAY LIKE 'W'.  "No dependecies found         ELSE.           SORT gt_objects BY pgmid object obj_name.         ENDIF.
*---------- Create ALV ----------*         cl_salv_table=>factory( IMPORTING r_salv_table = go_objects                                  CHANGING t_table      = gt_objects ).
*---------- Set ALV Functions ----------*         go_objects->set_screen_status(           pfstatus      = 'STATUS'           report        = sy-cprog           set_functions = go_objects->c_functions_all ).
*---------- Set Layout ----------*         lr_layout = go_objects->get_layout( ).         ls_key-report = sy-repid.         lr_layout->set_key( ls_key ).         lr_layout->set_save_restriction( ).
*---------- Set ALV selections ----------*         lr_selections = go_objects->get_selections( ).         lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
*---------- Set ALV Display and Title ----------*         lr_display = go_objects->get_display_settings( ).         lr_display->set_striped_pattern( if_salv_c_bool_sap=>true ).         lv_lines = lines( gt_objects ).         lv_lines_c = lv_lines.         CONDENSE lv_lines_c NO-GAPS.         CONCATENATE '(' lv_lines_c ')' INTO lv_lines_c.         CONCATENATE text-t01 p_pgmid p_object p_obj_n text-t02 lv_lines_c INTO lv_title SEPARATED BY space.         lr_display->set_list_header( lv_title ).
*---------- Set ALV Columns ----------*         lr_columns = go_objects->get_columns( ).         lr_columns->set_key_fixation( ).         lr_columns->set_optimize( ).         lt_column_ref = lr_columns->get( ).         LOOP AT lt_column_ref INTO ls_column_ref. "Default format for all columns           lr_column ?= lr_columns->get_column( ls_column_ref-columnname ).           lr_column->set_f4( if_salv_c_bool_sap=>false ).           lr_column->set_alignment( if_salv_c_alignment=>centered ).
*---------- Check status ----------*           IF ls_column_ref-columnname = 'STATUS'.             lr_column->set_key( if_salv_c_bool_sap=>true ).             lr_column->set_short_text( text-c06 ).  "Check St.             lr_column->set_medium_text( text-c06 ).             lr_column->set_long_text( text-c06 ).           ENDIF.
*---------- Object Keys ----------*           IF ls_column_ref-columnname = gc_pgmid OR              ls_column_ref-columnname = gc_object OR              ls_column_ref-columnname = 'OBJ_NAME'.             lr_column->set_key( if_salv_c_bool_sap=>true ).           ENDIF.
*---------- Object name and development package ----------*           IF ls_column_ref-columnname = 'OBJ_NAME' OR              ls_column_ref-columnname = 'DEVCLASS'.             lr_column->set_alignment( if_salv_c_alignment=>left ).           ENDIF.
*---------- Object description ----------*           IF ls_column_ref-columnname = 'OBJ_DESC'.             lr_column->set_alignment( if_salv_c_alignment=>left ).             lr_column->set_short_text( text-c01 ).  "Obj. Desc.             lr_column->set_medium_text( text-c01 ).             lr_column->set_long_text( text-c01 ).           ENDIF.
*---------- Source Language ----------*           IF ls_column_ref-columnname = 'SLANG'.             lr_column->set_short_text( text-c02 ).  "Source             lr_column->set_medium_text( text-c02 ).             lr_column->set_long_text( text-c02 ).           ENDIF.
*---------- Target Languages ----------*           IF ls_column_ref-columnname = 'TLANGS'.             lr_column->set_short_text( text-c03 ).  "Targets             lr_column->set_medium_text( text-c03 ).             lr_column->set_long_text( text-c03 ).           ENDIF.
*---------- Translation status ----------*           IF ls_column_ref-columnname = 'STATTRN'.             lr_column->set_short_text( text-c04 ).  "Trans. St.             lr_column->set_medium_text( text-c04 ).             lr_column->set_long_text( text-c04 ).           ENDIF.
*---------- Process status ----------*           IF ls_column_ref-columnname = 'STATPROC'.             lr_column->set_short_text( text-c05 ).  "Proc. St.             lr_column->set_medium_text( text-c05 ).             lr_column->set_long_text( text-c05 ).           ENDIF.         ENDLOOP.
*---------- Register ALV Events ----------*         lr_events = go_objects->get_event( ).         CREATE OBJECT lo_event_handler.         SET HANDLER lo_event_handler->on_user_command FOR lr_events.         SET HANDLER lo_event_handler->on_double_click FOR lr_events.
*---------- Display Objects ALV ----------*         go_objects->display( ).       CATCH cx_root INTO go_exp.                         "#EC CATCH_ALL         gv_msg_text = go_exp->get_text( ).         MESSAGE s398 WITH gv_msg_text space space space DISPLAY LIKE 'E'. "Critical error     ENDTRY.   ELSE. "Refresh ALV     go_objects->refresh( ).   ENDIF.
ENDFORM.                    " DISPLAY_OBJECTS
*---------------------------------------------------------- FORMS ADDS *
*----------------------------------------------- Form CHECK_ADD_OBJECT *
FORM check_add_object USING value(i_pgmid) TYPE pgmid i_object TYPE any i_obj_n TYPE any is_env_tab TYPE senvi.   DATA lo_wb_object TYPE REF TO cl_wb_object.  "Repository Object   DATA:     ls_tadir          TYPE tadir,               "Directory of Repository Objects     ls_wb_object_type TYPE wbobjtype,           "Global WB Type     ls_object         LIKE LINE OF gt_objects.  "Objects to transport line   DATA:     lv_tr_object   TYPE trobjtype,  "Object Type     lv_tr_obj_name TYPE trobj_name, "Object Name in Object List     lv_trans_pgmid TYPE pgmid.      "Program ID in Requests and Tasks
*---------- Object convertions ----------*   IF i_pgmid <> gc_r3tr.     SELECT pgmid UP TO 1 ROWS FROM tadir                "#EC CI_GENBUFF       INTO i_pgmid      WHERE object   = i_object        AND obj_name = i_obj_n.     ENDSELECT.
*---------- Is not a TADIR object and Conversion required ----------*     IF sy-subrc IS NOT INITIAL.       lv_tr_object   = i_object.       lv_tr_obj_name = i_obj_n.       cl_wb_object=>create_from_transport_key( EXPORTING p_object                = lv_tr_object                                                          p_obj_name              = lv_tr_obj_name                                                RECEIVING p_wb_object             = lo_wb_object                                               EXCEPTIONS objecttype_not_existing = 1                                                          empty_object_key        = 2                                                          key_not_available       = 3                                                          OTHERS                  = 4 ).       IF sy-subrc IS INITIAL.         lo_wb_object->get_global_wb_key( IMPORTING p_object_type     = ls_wb_object_type                                         EXCEPTIONS key_not_available = 1                                                    OTHERS            = 2 ).         IF sy-subrc IS INITIAL.           lo_wb_object->get_transport_key( IMPORTING p_pgmid           = lv_trans_pgmid "#EC CI_SUBRC                                           EXCEPTIONS key_not_available = 1                                                      OTHERS            = 2 ).
*---------- Check Program ID ----------*           CASE lv_trans_pgmid.             WHEN gc_r3tr.  "Main objects               i_pgmid = lv_trans_pgmid.             WHEN 'LIMU'.  "Sub object               CALL FUNCTION 'GET_R3TR_OBJECT_FROM_LIMU_OBJ'                 EXPORTING                   p_limu_objtype = lv_tr_object                   p_limu_objname = lv_tr_obj_name                 IMPORTING                   p_r3tr_objtype = lv_tr_object                   p_r3tr_objname = lv_tr_obj_name                 EXCEPTIONS                   no_mapping     = 1                   OTHERS         = 2.               IF sy-subrc IS INITIAL.                 ls_object-pgmid    = gc_r3tr.                 ls_object-object   = lv_tr_object.                 ls_object-obj_name = lv_tr_obj_name.                 PERFORM add_object USING ls_object.                 RETURN.               ENDIF.             WHEN OTHERS.  "Include objects               i_pgmid = gc_r3tr.               CALL FUNCTION 'GET_TADIR_TYPE_FROM_WB_TYPE'                 EXPORTING                   wb_objtype        = ls_wb_object_type-subtype_wb                 IMPORTING                   transport_objtype = lv_tr_object                 EXCEPTIONS                   no_mapping_found  = 1                   no_unique_mapping = 2                   OTHERS            = 3.               IF sy-subrc IS INITIAL.                 i_object = lv_tr_object.                 IF is_env_tab-encl_obj IS NOT INITIAL.                   i_obj_n = is_env_tab-encl_obj.                 ENDIF.               ENDIF.           ENDCASE.         ENDIF.  "Global WB key       ENDIF.  "Transport_key     ENDIF.  "No a TADIR   ENDIF.  "Convertions
*---------- Check in TADIR ----------*   SELECT SINGLE * FROM tadir     INTO ls_tadir    WHERE pgmid    = i_pgmid      AND object   = i_object      AND obj_name = i_obj_n.
*---------- Add object ----------*   IF ls_tadir IS NOT INITIAL.     MOVE-CORRESPONDING ls_tadir TO ls_object.
*---------- Set SAP Generated object status ----------*     IF ls_tadir-genflag IS NOT INITIAL.       ls_object-status = icon_led_yellow.     ENDIF.
*---------- Add object to be checked ----------*     PERFORM add_object USING ls_object.
*---------- Error Object not valid ----------*   ELSE.     IF lines( gt_objects ) > 0. "Skip first object       ls_object-pgmid    = i_pgmid.       ls_object-object   = i_object.       ls_object-obj_name = i_obj_n.       ls_object-status   = icon_led_red.       PERFORM add_object USING ls_object.     ENDIF.   ENDIF.
ENDFORM.                    "check_add_object
*----------------------------------------------------- Form ADD_OBJECT *
FORM add_object USING ps_object TYPE gty_objects.   DATA:     ls_objs_desc LIKE LINE OF gt_objs_desc,  "Objects prograns ID line"Info Environment     lt_devclass  TYPE scts_devclass,         "Development Packages     ls_devclass  TYPE trdevclass.   DATA:     lv_object    TYPE trobjtype,  "Object Type     lv_objname   TYPE sobj_name,  "Object Name in Object Directory     lv_namespace TYPE namespace.  "Object Namespace
*---------- Check if already added ----------*   READ TABLE gt_objects TRANSPORTING NO FIELDS WITH KEY pgmid    = ps_object-pgmid                                                         object   = ps_object-object                                                         obj_name = ps_object-obj_name.   IF sy-subrc IS NOT INITIAL. "New object
*---------- Check if is customer object ----------*     lv_object  = ps_object-object.     lv_objname = ps_object-obj_name.     CALL FUNCTION 'TRINT_GET_NAMESPACE'                     "#EC FB_RC       EXPORTING         iv_pgmid            = ps_object-pgmid         iv_object           = lv_object         iv_obj_name         = lv_objname       IMPORTING         ev_namespace        = lv_namespace       EXCEPTIONS         invalid_prefix      = 1         invalid_object_type = 2         OTHERS              = 3.     IF lv_namespace = '/0CUST/'.  "Is customer object
*---------- Read object description ----------*       READ TABLE gt_objs_desc INTO ls_objs_desc WITH KEY object = ps_object-object.       IF sy-subrc IS INITIAL.         ps_object-obj_desc = ls_objs_desc-text.  "Object type description       ENDIF.
*---------- Read development class tecnical information ----------*       IF ps_object-devclass IS INITIAL.         SELECT SINGLE devclass FROM tadir           INTO ps_object-devclass          WHERE pgmid    = ps_object-pgmid            AND object   = ps_object-object            AND obj_name = ps_object-obj_name.       ENDIF.       IF ps_object-devclass IS NOT INITIAL AND ps_object-devclass <> gc_temp.         ls_devclass-devclass = ps_object-devclass.         APPEND ls_devclass TO lt_devclass.         CALL FUNCTION 'TR_READ_DEVCLASSES'           EXPORTING             it_devclass = lt_devclass           IMPORTING             et_devclass = lt_devclass.         READ TABLE lt_devclass INTO ls_devclass INDEX 1.         IF sy-subrc IS INITIAL.           ps_object-target = ls_devclass-target.  "Development package target         ENDIF.       ENDIF.       ps_object-slang  = p_slang.       ps_object-tlangs = gv_tlangs.
*---------- Add object to transport ----------*       APPEND ps_object TO gt_objects.     ENDIF.   ENDIF.
ENDFORM.                    " ADD_OBJECT
*-------------------------------------------------------- FORMS CHECKS *
*----------------------------------------------------- Form RUN_CHECKS *
FORM run_checks .   TRY.
*---------- Dependecies check ----------*       PERFORM objects_dependencies_check.
*---------- Translations check ----------*       PERFORM objects_translations_check.     CATCH cx_root INTO go_exp.                           "#EC CATCH_ALL       gv_msg_text = go_exp->get_text( ).       MESSAGE s398 WITH gv_msg_text space space space DISPLAY LIKE 'E'. "Critical error   ENDTRY.
ENDFORM.                    " RUN_CHECKS
*------------------------------------- Form OBJECTS_DEPENDENCIES_CHECK *
FORM objects_dependencies_check .   DATA:     lv_obj_type TYPE seu_obj,         "Object type     lt_env_tab  TYPE TABLE OF senvi,  "Object to check dependencies     ls_env_tab  TYPE senvi.           "Info Environment   FIELD-SYMBOLS <ls_object> LIKE LINE OF gt_objects.  "Objects to transport   PERFORM progress_bar USING text-p02 '30'. "Checking Dependecies   LOOP AT gt_objects ASSIGNING <ls_object> WHERE status IS INITIAL.
*---------- Get object dependecies ----------*     REFRESH lt_env_tab.     lv_obj_type = <ls_object>-object.     CALL FUNCTION 'REPOSITORY_ENVIRONMENT_RFC'       EXPORTING         obj_type        = lv_obj_type         object_name     = <ls_object>-obj_name       TABLES         environment_tab = lt_env_tab.     DELETE lt_env_tab INDEX 1.  "Delete first line
*---------- Add founded dependecies ----------*     LOOP AT lt_env_tab INTO ls_env_tab.                  "#EC CI_NESTED       PERFORM check_add_object USING space ls_env_tab-type ls_env_tab-object ls_env_tab.     ENDLOOP.     <ls_object>-status = icon_led_green.  "Status checked   ENDLOOP.
ENDFORM.                    " OBJECTS_DEPENDENCIES_CHECK
*------------------------------------- Form OBJECTS_TRANSLATIONS_CHECK *
FORM objects_translations_check .   DATA:     lt_colob      TYPE TABLE OF lxe_colob,    "Object Lists     ls_colob      LIKE LINE OF lt_colob,     ls_objs_colob LIKE LINE OF gt_objs_colob, "LXE Objects     ls_tlang      LIKE LINE OF so_tlang,      "Target Languages     ls_language   LIKE LINE OF gt_languages,  "Languages Informations     ls_slanguage  LIKE LINE OF gt_languages.   DATA:     lv_tr_obj_name TYPE trobj_name, "Object Name in Object List     lv_stattrn     TYPE lxestattrn. "Translation Status of an Object   FIELD-SYMBOLS <ls_object> LIKE LINE OF gt_objects.  "Objects to transport   PERFORM progress_bar USING text-p03 '60'. "Checking Translations
*---------- Checking Translations ----------*   REFRESH gt_objs_colob.   LOOP AT gt_objects ASSIGNING <ls_object> WHERE status = icon_led_green.     REFRESH lt_colob.     lv_tr_obj_name = <ls_object>-obj_name.     CALL FUNCTION 'LXE_OBJ_EXPAND_TRANSPORT_OBJ'       EXPORTING         pgmid           = <ls_object>-pgmid         object          = <ls_object>-object         obj_name        = lv_tr_obj_name       TABLES         ex_colob        = lt_colob       EXCEPTIONS         unknown_object  = 1         unknown_ta_type = 2         OTHERS          = 3.
*---------- Check Status ----------*     IF sy-subrc IS NOT INITIAL. "Error       <ls_object>-status = icon_led_red.       CONTINUE.     ENDIF.     IF lt_colob IS INITIAL. "No translation       <ls_object>-status = icon_led_yellow.     ENDIF.
*---------- Initial Translation status ----------*
*---------- Add to global LXE object tables ----------*     LOOP AT lt_colob INTO ls_colob.                      "#EC CI_NESTED       MOVE-CORRESPONDING <ls_object> TO ls_objs_colob.       MOVE-CORRESPONDING ls_colob    TO ls_objs_colob.       APPEND ls_objs_colob TO gt_objs_colob.       CLEAR ls_objs_colob.       IF <ls_object>-stattrn <> icon_led_yellow.
*---------- Loop selected target language ----------*         LOOP AT so_tlang INTO ls_tlang.                  "#EC CI_NESTED           READ TABLE gt_languages INTO ls_language WITH KEY laiso = ls_tlang-low. "Read language tecnical info           READ TABLE gt_languages INTO ls_slanguage WITH KEY laiso = p_slang.           CLEAR lv_stattrn.           CALL FUNCTION 'LXE_OBJ_TRANSLATION_STATUS2'             EXPORTING               t_lang  = ls_language-o_language               s_lang  = ls_slanguage-o_language               custmnr = ls_colob-custmnr               objtype = ls_colob-objtype               objname = ls_colob-objname             IMPORTING               stattrn = lv_stattrn.           IF lv_stattrn = 'T'.  "Translated             <ls_object>-stattrn = icon_led_green.           ELSE.             <ls_object>-stattrn = icon_led_yellow.             EXIT.           ENDIF.         ENDLOOP.  "Target Languagues       ENDIF.  "Status     ENDLOOP.  "LXE Objects   ENDLOOP.  "Objects
ENDFORM.                    " OBJECTS_TRANSLATIONS_CHECK
*------------------------------------------------------- FORMS OPTIONS *
*----------------------------------------------- Form CREATE_TRANSPORT *
FORM create_transport TABLES lt_objects TYPE STANDARD TABLE. "#EC PF_NO_TYPE   DATA:     lt_e071_temp  TYPE TABLE OF e071,         "Change & Transport System: Object Entries of Requests/Tasks     lt_e071       TYPE TABLE OF e071,     lt_e071k_temp TYPE TABLE OF e071k,     ls_object     LIKE LINE OF gt_objects,     lt_targets    TYPE TABLE OF tr_target,    "Transport Target of Request     ls_target     LIKE LINE OF lt_targets,     ls_objs_colob LIKE LINE OF gt_objs_colob, "LXE Objects     ls_tlang      LIKE LINE OF so_tlang.      "Target Languages   DATA:     lv_order TYPE trkorr, "Request/Task     lv_task  TYPE trkorr.
*---------- Check selected objects to transport ----------*   LOOP AT lt_objects INTO ls_object.     IF ls_object-devclass = gc_temp.       MESSAGE i398 WITH text-m10 space space space DISPLAY LIKE 'E'.  "Request canceled, at least one object $TEMP detected       RETURN.     ENDIF.     ls_target = ls_object-target.     APPEND ls_target TO lt_targets.   ENDLOOP.
*---------- Check targets ----------*   SORT lt_targets.   DELETE ADJACENT DUPLICATES FROM lt_targets.   IF lines( lt_targets ) > 1. "Only one valid target     MESSAGE i398 WITH text-m05 space space space. "Transport not allowed for multiple targets     RETURN.   ENDIF.
*---------- Add translations to transport ----------*   LOOP AT lt_objects INTO ls_object.     LOOP AT gt_objs_colob INTO ls_objs_colob WHERE pgmid    = ls_object-pgmid "#EC CI_NESTED                                                AND object   = ls_object-object                                                AND obj_name = ls_object-obj_name.       LOOP AT so_tlang INTO ls_tlang.                    "#EC CI_NESTED         CALL FUNCTION 'LXE_OBJ_CREATE_TRANSPORT_SE63'           EXPORTING             language = ls_tlang-low             custmnr  = ls_objs_colob-custmnr             objtype  = ls_objs_colob-objtype             objname  = ls_objs_colob-objname           TABLES             ex_e071  = lt_e071_temp.         APPEND LINES OF lt_e071_temp TO lt_e071.         REFRESH lt_e071_temp.       ENDLOOP.     ENDLOOP.   ENDLOOP.
*---------- Check selected translations ----------*   IF lt_e071 IS INITIAL.     MESSAGE i398 WITH text-m04 space space space. "No objects selected     RETURN.   ENDIF.
*---------- Create or Select transport request ----------*   READ TABLE lt_targets INTO ls_target INDEX 1.   CALL FUNCTION 'TRINT_ORDER_CHOICE'     EXPORTING       iv_tarsystem           = ls_target     IMPORTING       we_order               = lv_order       we_task                = lv_task     TABLES       wt_e071                = lt_e071_temp       wt_e071k               = lt_e071k_temp     EXCEPTIONS       no_correction_selected = 1       display_mode           = 2       object_append_error    = 3       recursive_call         = 4       wrong_order_type       = 5       OTHERS                 = 6.
*---------- Add object to transport request ----------*   IF sy-subrc IS INITIAL AND lv_task IS NOT INITIAL.     REFRESH lt_e071k_temp.     CALL FUNCTION 'TRINT_APPEND_COMM'       EXPORTING         wi_exclusive       = abap_false         wi_sel_e071        = abap_true         wi_sel_e071k       = abap_true         wi_trkorr          = lv_task       TABLES         wt_e071            = lt_e071         wt_e071k           = lt_e071k_temp       EXCEPTIONS         e071k_append_error = 1         e071_append_error  = 2         trkorr_empty       = 3         OTHERS             = 4.
*---------- Sort and compress request --------*     IF sy-subrc IS INITIAL. "Added with sucess       CALL FUNCTION 'TR_SORT_AND_COMPRESS_COMM' "#EC FB_RC   "#EC CI_SUBRC         EXPORTING           iv_trkorr                      = lv_task         EXCEPTIONS           trkorr_not_found               = 1           order_released                 = 2           error_while_modifying_obj_list = 3           tr_enqueue_failed              = 4           no_authorization               = 5           OTHERS                         = 6.       MESSAGE i398 WITH text-m07 lv_order space space DISPLAY LIKE 'S'.  "Objects added to request     ELSE.       MESSAGE i398 WITH text-ex2 space space space DISPLAY LIKE 'E'.  "Executed with errors     ENDIF.  "Added   ELSE.     MESSAGE s398 WITH text-m09 space space space DISPLAY LIKE 'W'.  "Transport canceled   ENDIF.
ENDFORM.                    " CREATE_TRANSPORT
*---------------------------------------------- Form COPY_TRANSLATIONS *
FORM copy_translations TABLES lt_objects TYPE STANDARD TABLE. "#EC PF_NO_TYPE   DATA:       ls_object     LIKE LINE OF gt_objects,    "Objects to transport       ls_objs_colob LIKE LINE OF gt_objs_colob, "LXE Objects       ls_tlang      LIKE LINE OF so_tlang,      "Target Languages       lt_pcx_s1     TYPE TABLE OF lxe_pcx_s1,   "Text Pairs       ls_pcx_s1     LIKE LINE OF lt_pcx_s1,       ls_tlanguage   LIKE LINE OF gt_languages, "Languages Informations       ls_slanguage  LIKE LINE OF gt_languages.   DATA:     lv_pstatus TYPE lxestatprc, "Process Status     lv_stattrn TYPE lxestattrn. "Translation Status of an Object   FIELD-SYMBOLS:     <ls_pcx_s1> LIKE LINE OF lt_pcx_s1,   "Text Pairs     <ls_object> LIKE LINE OF gt_objects.  "Objects to translate
*---------- Read source language details ----------*   READ TABLE gt_languages INTO ls_slanguage WITH KEY laiso = p_slang.
*---------- Loop all selected objects ----------*   LOOP AT lt_objects INTO ls_object.
*---------- Loop LXE Sub-Objects ----------*     LOOP AT gt_objs_colob INTO ls_objs_colob WHERE pgmid    = ls_object-pgmid "#EC CI_NESTED                                                AND object   = ls_object-object                                                AND obj_name = ls_object-obj_name.
*---------- Loop selected target language ----------*       LOOP AT so_tlang INTO ls_tlang.
*---------- Read target language details ----------*         CLEAR ls_tlanguage.         READ TABLE gt_languages INTO ls_tlanguage WITH KEY laiso = ls_tlang-low. "Read language tecnical info
*---------- Read texts ----------*         CLEAR lv_pstatus.         REFRESH lt_pcx_s1.         CALL FUNCTION 'LXE_OBJ_TEXT_PAIR_READ'           EXPORTING             t_lang    = ls_tlanguage-o_language             s_lang    = ls_slanguage-o_language             custmnr   = ls_objs_colob-custmnr             objtype   = ls_objs_colob-objtype             objname   = ls_objs_colob-objname             read_only = space           IMPORTING             pstatus   = lv_pstatus           TABLES             lt_pcx_s1 = lt_pcx_s1.         IF lv_pstatus <> 'S' OR lt_pcx_s1 IS INITIAL. "Not Successful or empty           CONTINUE.         ENDIF.
*---------- Copy and check Overwrite ----------*         IF p_ow IS INITIAL.           LOOP AT lt_pcx_s1 ASSIGNING <ls_pcx_s1> WHERE t_text IS INITIAL. "#EC CI_NESTED             <ls_pcx_s1>-t_text = <ls_pcx_s1>-s_text.           ENDLOOP.         ELSE.           LOOP AT lt_pcx_s1 ASSIGNING <ls_pcx_s1>.       "#EC CI_NESTED             <ls_pcx_s1>-t_text = <ls_pcx_s1>-s_text.           ENDLOOP.         ENDIF.
*---------- Update texts ----------*         CALL FUNCTION 'LXE_OBJ_TEXT_PAIR_WRITE'           EXPORTING             t_lang    = ls_tlanguage-o_language             s_lang    = ls_slanguage-o_language             custmnr   = ls_objs_colob-custmnr             objtype   = ls_objs_colob-objtype             objname   = ls_objs_colob-objname           TABLES             lt_pcx_s1 = lt_pcx_s1.
*---------- Create proposal and check status ----------*         LOOP AT lt_pcx_s1 INTO ls_pcx_s1 WHERE t_text IS NOT INITIAL. "#EC CI_NESTED           CALL FUNCTION 'LXE_PP1_PROPOSAL_EDIT_SE63'             EXPORTING               t_lang         = ls_tlanguage-o_language               s_lang         = ls_slanguage-o_language               custmnr        = ls_objs_colob-custmnr               objtype        = ls_objs_colob-objtype               domatyp        = ls_objs_colob-domatyp               domanam        = ls_objs_colob-domanam               pcx_s1         = ls_pcx_s1               direct_command = 'ASTX'               direct_status  = '69'.         ENDLOOP.  "Proposal
*---------- Check and update translation status ----------*         READ TABLE gt_objects ASSIGNING <ls_object> WITH KEY pgmid    = ls_object-pgmid                                                              object   = ls_object-object                                                              obj_name = ls_object-obj_name.         IF sy-subrc IS INITIAL AND <ls_object>-statproc <> icon_led_yellow.           CLEAR lv_stattrn.           CALL FUNCTION 'LXE_OBJ_TRANSLATION_STATUS2'             EXPORTING               t_lang  = ls_tlanguage-o_language               s_lang  = ls_slanguage-o_language               custmnr = ls_objs_colob-custmnr               objtype = ls_objs_colob-objtype               objname = ls_objs_colob-objname             IMPORTING               stattrn = lv_stattrn.
*---------- Process Translation status ----------*           IF lv_stattrn = 'T'.  "Translated             <ls_object>-statproc = icon_led_green.           ELSE.             <ls_object>-statproc = icon_led_yellow.           ENDIF.         ENDIF.       ENDLOOP.  "Target language     ENDLOOP.    "LXE Sub-Objects   ENDLOOP.      "Objects   MESSAGE i398 WITH text-ex1 space space space DISPLAY LIKE 'S'. "Executed with success
ENDFORM.                    " COPY_TRANSLATIONS
*---------------------------------------------- Form DOWNLOAD_TEMPLATE *
FORM download_template TABLES lt_objects TYPE STANDARD TABLE. "#EC PF_NO_TYPE   DATA:     ls_object     LIKE LINE OF gt_objects,    "Objects to transport     ls_tlanguage  LIKE LINE OF gt_languages,  "Languages Informations     ls_slanguage  LIKE LINE OF gt_languages,     ls_tlang      LIKE LINE OF so_tlang,      "Target Languages     lt_pcx_s1     TYPE TABLE OF lxe_pcx_s1,   "Text Pairs     ls_objs_colob LIKE LINE OF gt_objs_colob, "LXE Objects     ls_pcx_s1     LIKE LINE OF lt_pcx_s1.   DATA:     lv_filename          TYPE string,     "File     lv_path              TYPE string,     lv_fullpath          TYPE string,     lv_window_title      TYPE string,     "Popup Windows Title     lv_default_file_name TYPE string,     "Default file     lv_user_action       TYPE i,          "User Actions     lv_object            TYPE string,     "Excel object     lv_lxe_object        TYPE string,     "LXE object     lv_column            TYPE i VALUE 1,  "Excel Columns     lv_row               TYPE i VALUE 1,  "Excel rows     lv_row_lang          TYPE i,          "Excel languages rows     lv_lang_txt          TYPE string,     "Language description     lv_add_row           TYPE abap_bool,  "Add new row to excel flag     lv_row_init          TYPE i.          "Language start row   DATA:     lo_application TYPE ole2_object,  "OLE Automation Controller: OLE Typen     lo_workbook    TYPE ole2_object,     lo_worksheet   TYPE ole2_object,     lo_column      TYPE ole2_object.
*---------- Save file dialog ----------*   lv_window_title = text-g02. "Download Template   READ TABLE gt_languages INTO ls_slanguage WITH KEY laiso = p_slang.   CONCATENATE p_obj_n ls_slanguage-r3_lang text-f01 gv_tlangs INTO lv_default_file_name SEPARATED BY space.   CONCATENATE lv_default_file_name '.' gc_excel_ext INTO lv_default_file_name.   CALL METHOD cl_gui_frontend_services=>file_save_dialog     EXPORTING       window_title         = lv_window_title       default_extension    = gc_excel_ext       default_file_name    = lv_default_file_name       prompt_on_overwrite  = abap_false     CHANGING       filename             = lv_filename       path                 = lv_path       fullpath             = lv_fullpath       user_action          = lv_user_action     EXCEPTIONS       cntl_error           = 1       error_no_gui         = 2       not_supported_by_gui = 3       OTHERS               = 4.   IF sy-subrc IS NOT INITIAL.     MESSAGE i398 WITH text-ex2 space space space DISPLAY LIKE 'E'. "Executed with errors     RETURN.   ENDIF.
*---------- Create excel ----------*   IF lv_user_action IS INITIAL.     CREATE OBJECT lo_application 'excel.application'.       "#EC NOTEXT     IF sy-subrc IS NOT INITIAL.       MESSAGE i398 WITH text-ex2 space space space DISPLAY LIKE 'E'. "Executed with errors       RETURN.     ENDIF.     SET PROPERTY OF lo_application 'visible' = 0.           "#EC NOTEXT
*---------- Create Workbook ----------*     CALL METHOD OF lo_application 'Workbooks' = lo_workbook.  "Get Workbook     SET PROPERTY OF lo_application 'SheetsInNewWorkbook' = 1.     CALL METHOD OF lo_workbook 'Add'.                         "Create Workbook
*---------- Create Worksheet ----------*     CALL METHOD OF lo_application 'Worksheets' = lo_worksheet "Get worksheet       EXPORTING #1 = 1.     CALL METHOD OF lo_worksheet 'Activate'.                   "Activate worksheet     SET PROPERTY OF lo_worksheet 'Name' = text-f01.         "#EC NOTEXT
*---------- Create Header Column Object ----------*     PERFORM create_cell USING lv_row lv_column gc_object abap_true CHANGING lo_worksheet.
*---------- Create Header Column LXE Object ----------*     ADD 1 TO lv_column.     PERFORM create_cell USING lv_row lv_column gc_lxe_object abap_true CHANGING lo_worksheet.
*---------- Create Header Column Text Pair ----------*     ADD 1 TO lv_column.     PERFORM create_cell USING lv_row lv_column gc_textkey abap_true CHANGING lo_worksheet.
*---------- Create Header Column Source Language column ----------*     ADD 1 TO lv_column.     CONCATENATE ls_slanguage-r3_lang ls_slanguage-text INTO lv_lang_txt SEPARATED BY space.     PERFORM create_cell USING lv_row lv_column lv_lang_txt abap_true CHANGING lo_worksheet.
*---------- Create Header Columns Target Languages ----------*     LOOP AT so_tlang INTO ls_tlang.       READ TABLE gt_languages INTO ls_tlanguage WITH KEY laiso = ls_tlang-low. "Read language tecnical info       IF sy-subrc IS INITIAL.         ADD 1 TO lv_column.         CONCATENATE ls_tlanguage-r3_lang ls_tlanguage-text INTO lv_lang_txt SEPARATED BY space.         PERFORM create_cell USING lv_row lv_column lv_lang_txt abap_true CHANGING lo_worksheet.       ENDIF.     ENDLOOP.
*---------- Loop all selected objects ----------*     LOOP AT lt_objects INTO ls_object.       CONCATENATE ls_object-pgmid ls_object-object ls_object-obj_name INTO lv_object SEPARATED BY space.       lv_add_row = abap_true. "Set add rows for new object       lv_column = 4.          "Start text column       lv_row_init = lv_row.   "Get init row
*---------- Create Column by target languague ----------*       LOOP AT so_tlang INTO ls_tlang.                    "#EC CI_NESTED         ADD 1 TO lv_column.         CLEAR ls_tlanguage.         READ TABLE gt_languages INTO ls_tlanguage WITH KEY laiso = ls_tlang-low. "Read language tecnical info
*---------- Create Rows by LXE object ----------*         LOOP AT gt_objs_colob INTO ls_objs_colob WHERE pgmid    = ls_object-pgmid "#EC CI_NESTED                                                    AND object   = ls_object-object                                                    AND obj_name = ls_object-obj_name.           CONCATENATE ls_objs_colob-objtype ls_objs_colob-objname INTO lv_lxe_object SEPARATED BY space.
*---------- Read texts ----------*           REFRESH lt_pcx_s1.           CALL FUNCTION 'LXE_OBJ_TEXT_PAIR_READ'             EXPORTING               t_lang    = ls_tlanguage-o_language               s_lang    = ls_slanguage-o_language               custmnr   = ls_objs_colob-custmnr               objtype   = ls_objs_colob-objtype               objname   = ls_objs_colob-objname             TABLES               lt_pcx_s1 = lt_pcx_s1.
*---------- Create Rows (LXE Object) ----------*           lv_row_lang = lv_row_init.           LOOP AT lt_pcx_s1 INTO ls_pcx_s1.              "#EC CI_NESTED             IF lv_add_row IS NOT INITIAL.               ADD 1 TO lv_row.               lv_row_lang = lv_row.
*---------- Create Rows (Object) ----------*               PERFORM create_cell USING lv_row 1 lv_object abap_true CHANGING lo_worksheet.
*---------- Create Rows (LXE Object) ----------*               PERFORM create_cell USING lv_row 2 lv_lxe_object abap_true CHANGING lo_worksheet.
*---------- Create Rows (Text Pair) ----------*               PERFORM create_cell USING lv_row 3 ls_pcx_s1-textkey abap_true CHANGING lo_worksheet.
*---------- Create Rows (LXE Object Source Language) ----------*               PERFORM create_cell USING lv_row 4 ls_pcx_s1-s_text abap_true CHANGING lo_worksheet.             ELSE.               ADD 1 TO lv_row_lang.             ENDIF.
*---------- Create Rows (LXE Object Target languague ) ----------*             PERFORM create_cell USING lv_row_lang lv_column ls_pcx_s1-t_text abap_false CHANGING lo_worksheet.           ENDLOOP.  "Rows         ENDLOOP.  "LXE object         CLEAR lv_add_row.       ENDLOOP.  "Column     ENDLOOP.  "Selected objects
*---------- Format Columns ----------*     CALL METHOD OF lo_application 'Columns' = lo_column.  "Get Column     CALL METHOD OF lo_column 'Autofit'.                   "Set Column Autofit
*---------- Save excel worksheet ----------*     CALL METHOD OF lo_worksheet 'SaveAs'                  "Save excel       EXPORTING #1 = lv_fullpath.     IF sy-subrc IS INITIAL.
*---------- Closes excel window ----------*       CALL METHOD OF lo_workbook 'CLOSE'.                   "Close Workbook       SET PROPERTY OF lo_application 'DisplayAlerts' = 0.       CALL METHOD OF lo_application 'QUIT'.                 "End excel       FREE OBJECT: lo_column, lo_worksheet, lo_workbook, lo_application.       MESSAGE i398 WITH text-ex1 space space space DISPLAY LIKE 'S'. "Executed with success     ELSE.       MESSAGE i398 WITH text-ex2 space space space DISPLAY LIKE 'E'. "Executed with errors       RETURN.     ENDIF.   ENDIF.
ENDFORM.                    " DOWNLOAD_TEMPLATE
*----------------------------------------------- Form UPLOAD_TEMPLATE *
FORM upload_template TABLES lt_objects TYPE STANDARD TABLE. "#EC PF_NO_TYPE   DATA:     ls_object          LIKE LINE OF gt_objects,                   "Object to transport     lt_files           TYPE TABLE OF file_table,                  "Files names     ls_file            LIKE LINE OF lt_files,     lt_excel_data      TYPE TABLE OF alsmex_tabline,              "Rows for Table with Excel Data     ls_excel_data      LIKE LINE OF lt_excel_data,     lt_component_table TYPE cl_abap_structdescr=>component_table, "Component Description Table     ls_component_table LIKE LINE OF lt_component_table,     ls_tlanguage       LIKE LINE OF gt_languages,                 "Languages Informations     ls_slanguage       LIKE LINE OF gt_languages,     ls_objs_colob      LIKE LINE OF gt_objs_colob,                "LXE Objects     lt_pcx_s1          TYPE TABLE OF lxe_pcx_s1,                  "Text Pairs     ls_pcx_s1          LIKE LINE OF lt_pcx_s1,     ls_tlang           LIKE LINE OF so_tlang.                     "Target Languages   DATA:     lo_data        TYPE REF TO data,                "Generic data     lo_data_line   TYPE REF TO data,     lo_excel_table TYPE REF TO cl_abap_tabledescr,  "Runtime Type Services     lo_excel_type  TYPE REF TO cl_abap_structdescr.   DATA:     lv_title       TYPE string,      "Window title     lv_rc          TYPE i,           "User action     lv_filename    TYPE localfile,   "File Name     lv_object      TYPE string,      "Object     lv_pstatus     TYPE lxestatprc,  "Process Status     lv_stattrn     TYPE lxestattrn,  "Translation Status of an Object     lv_lxe_object  TYPE string,      "LXE object     lv_tlang_exist TYPE abap_bool,  "Target Language flag     lv_modify      TYPE abap_bool.   FIELD-SYMBOLS:     <lt_excel_table> TYPE STANDARD TABLE,      "Dynamic excel     <ls_excel_table> TYPE any,     <field>          TYPE any,                 "Field pointer     <ls_pcx_s1>      LIKE LINE OF lt_pcx_s1,   "Text Pairs     <ls_object>      LIKE LINE OF gt_objects.  "Objects to translate
*---------- Open file dialog ----------*   lv_title = text-g01.  "Upload Template   CALL METHOD cl_gui_frontend_services=>file_open_dialog     EXPORTING       window_title            = lv_title       default_filename        = '*.xlsx'     CHANGING       file_table              = lt_files       rc                      = lv_rc     EXCEPTIONS       file_open_dialog_failed = 1       cntl_error              = 2       error_no_gui            = 3       not_supported_by_gui    = 4       OTHERS                  = 5.   IF sy-subrc IS NOT INITIAL.     MESSAGE i398 WITH text-ex2 space space space DISPLAY LIKE 'E'. "Executed with errors     RETURN.   ENDIF.
*---------- Read excel ----------*   IF lv_rc = 1.     READ TABLE lt_files INTO ls_file INDEX 1.     IF sy-subrc IS INITIAL.
*---------- Upload excel ----------*       lv_filename = ls_file-filename.       CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'         EXPORTING           filename                = lv_filename           i_begin_col             = 1           i_begin_row             = 1           i_end_col               = 10000           i_end_row               = 10000         TABLES           intern                  = lt_excel_data         EXCEPTIONS           inconsistent_parameters = 1           upload_ole              = 2           OTHERS                  = 3.       IF sy-subrc IS NOT INITIAL OR lt_excel_data IS INITIAL.         MESSAGE i398 WITH text-m02 space space space DISPLAY LIKE 'E'. "Error opening file         RETURN.       ENDIF.
*---------- Create dynamic table structure ----------*       LOOP AT lt_excel_data INTO ls_excel_data WHERE row = 1.         CASE ls_excel_data-col.           WHEN 1. "Object             IF ls_excel_data-value <> gc_object.               MESSAGE i398 WITH text-m11 space space space DISPLAY LIKE 'E'. "File not valid               RETURN.             ENDIF.             ls_component_table-name = gc_object.  "Object Type             ls_component_table-type = cl_abap_elemdescr=>get_c( '48' ).           WHEN 2. "LXE Object             IF ls_excel_data-value <> gc_lxe_object.               MESSAGE i398 WITH text-m11 space space space DISPLAY LIKE 'E'. "File not valid               RETURN.             ENDIF.             ls_component_table-name = gc_lxe_object. "LXE Object             ls_component_table-type = cl_abap_elemdescr=>get_c( '75' ).           WHEN 3. "Text Pair             IF ls_excel_data-value <> gc_textkey.               MESSAGE i398 WITH text-m11 space space space DISPLAY LIKE 'E'. "File not valid               RETURN.             ENDIF.             ls_component_table-name = gc_textkey.  "Text pair             ls_component_table-type = cl_abap_elemdescr=>get_c( '32' ).           WHEN 4. "Source language             READ TABLE gt_languages INTO ls_slanguage WITH KEY laiso = p_slang.             IF ls_excel_data-value(2) <> ls_slanguage-r3_lang.               MESSAGE i398 WITH text-m12 space space space DISPLAY LIKE 'E'. "File source language not valid               RETURN.             ENDIF.             ls_component_table-name = ls_excel_data-value(2).  "Languagues             ls_component_table-type = cl_abap_elemdescr=>get_c( '132' ).           WHEN OTHERS. "Target languages             READ TABLE gt_languages INTO ls_tlanguage WITH KEY r3_lang = ls_excel_data-value(2).             IF sy-subrc IS INITIAL.               lv_tlang_exist = abap_true.             ENDIF.             ls_component_table-name = ls_excel_data-value(2).  "Languagues             ls_component_table-type = cl_abap_elemdescr=>get_c( '132' ).         ENDCASE.         APPEND ls_component_table TO lt_component_table.         CLEAR ls_component_table.       ENDLOOP.       IF lv_tlang_exist IS INITIAL.         MESSAGE i398 WITH text-m13 space space space DISPLAY LIKE 'E'. "File target languages not valid         RETURN.       ENDIF.
*---------- Create dynamic table ----------*       IF lt_component_table IS NOT INITIAL.         lo_excel_type = cl_abap_structdescr=>create( lt_component_table ).         lo_excel_table = cl_abap_tabledescr=>create( p_line_type  = lo_excel_type                                                      p_table_kind = cl_abap_tabledescr=>tablekind_std                                                      p_unique     = abap_false ).         CREATE DATA lo_data TYPE HANDLE lo_excel_table.         ASSIGN lo_data->* TO <lt_excel_table>.         IF <lt_excel_table> IS ASSIGNED.           CREATE DATA lo_data_line LIKE LINE OF <lt_excel_table>.           ASSIGN lo_data_line->* TO <ls_excel_table>.         ENDIF.       ENDIF.       IF <lt_excel_table> IS NOT ASSIGNED OR <ls_excel_table> IS NOT ASSIGNED.         MESSAGE i398 WITH text-ex2 space space space DISPLAY LIKE 'E'. "Executed with errors         RETURN.       ENDIF.
*---------- Fill dynamic table with excel data ----------*       LOOP AT lt_excel_data INTO ls_excel_data WHERE row > 1.         AT NEW row.                                     "#EC AT_LOOP_WH           APPEND INITIAL LINE TO <lt_excel_table> ASSIGNING <ls_excel_table>.         ENDAT.         READ TABLE lt_component_table INTO ls_component_table INDEX ls_excel_data-col.         IF sy-subrc IS INITIAL.           ASSIGN COMPONENT ls_component_table-name OF STRUCTURE <ls_excel_table> TO <field>.           IF <field> IS NOT ASSIGNED.             CONTINUE.           ENDIF.         ENDIF.         <field> = ls_excel_data-value.       ENDLOOP.       IF <lt_excel_table> IS INITIAL.         MESSAGE i398 WITH text-m04 space space space DISPLAY LIKE 'W'. "No objects selected       ENDIF.
*---------- Translate upload excel data ----------*
*---------- Loop all selected objects ----------*       LOOP AT lt_objects INTO ls_object.                 "#EC CI_NESTED         CONCATENATE ls_object-pgmid ls_object-object ls_object-obj_name INTO lv_object SEPARATED BY space.         READ TABLE <lt_excel_table> ASSIGNING <ls_excel_table> WITH KEY (gc_object) = lv_object.  "Check if object exist in file         IF sy-subrc IS NOT INITIAL. "Object not found in file           CONTINUE.         ENDIF.
*---------- Loop LXE Sub-Objects ----------*         LOOP AT gt_objs_colob INTO ls_objs_colob WHERE pgmid    = ls_object-pgmid "#EC CI_NESTED                                                    AND object   = ls_object-object                                                    AND obj_name = ls_object-obj_name.           CONCATENATE ls_objs_colob-objtype ls_objs_colob-objname INTO lv_lxe_object SEPARATED BY space.           READ TABLE <lt_excel_table> ASSIGNING <ls_excel_table> WITH KEY (gc_object)     = lv_object "Check if object exist in file                                                                           (gc_lxe_object) = lv_lxe_object.           IF sy-subrc IS NOT INITIAL. "Object not found in file             CONTINUE.           ENDIF.
*---------- Loop selected target language ----------*           LOOP AT so_tlang INTO ls_tlang.             CLEAR ls_tlanguage.             READ TABLE gt_languages INTO ls_tlanguage WITH KEY laiso = ls_tlang-low. "Read language tecnical info             READ TABLE lt_component_table TRANSPORTING NO FIELDS WITH KEY name = ls_tlanguage-r3_lang. "Check if target language exist             IF sy-subrc IS NOT INITIAL. "Target Language found               CONTINUE.             ENDIF.
*---------- Read texts ----------*             CLEAR lv_pstatus.             REFRESH lt_pcx_s1.             CALL FUNCTION 'LXE_OBJ_TEXT_PAIR_READ'               EXPORTING                 t_lang    = ls_tlanguage-o_language                 s_lang    = ls_slanguage-o_language                 custmnr   = ls_objs_colob-custmnr                 objtype   = ls_objs_colob-objtype                 objname   = ls_objs_colob-objname                 read_only = space               IMPORTING                 pstatus   = lv_pstatus               TABLES                 lt_pcx_s1 = lt_pcx_s1.             IF lv_pstatus <> 'S' OR lt_pcx_s1 IS INITIAL. "Not Successful or empty               CONTINUE.             ENDIF.
*---------- Update and check Overwrite ----------*             CLEAR lv_modify.             LOOP AT lt_pcx_s1 ASSIGNING <ls_pcx_s1>.     "#EC CI_NESTED               IF p_ow IS INITIAL AND <ls_pcx_s1>-t_text IS NOT INITIAL. "Check Overwrite                 CONTINUE.               ENDIF.               READ TABLE <lt_excel_table> ASSIGNING <ls_excel_table> WITH KEY (gc_object)     = lv_object                                                                               (gc_lxe_object) = lv_lxe_object                                                                               (gc_textkey)    = <ls_pcx_s1>-textkey.               IF sy-subrc IS INITIAL.                 ASSIGN COMPONENT ls_tlanguage-r3_lang OF STRUCTURE <ls_excel_table> TO <field>.                 IF sy-subrc IS INITIAL.                   IF <field> IS NOT INITIAL.                     <ls_pcx_s1>-t_text = <field>.                     lv_modify = abap_true.                   ENDIF.                 ENDIF.               ENDIF.             ENDLOOP.
*---------- Update texts ----------*             IF lv_modify IS NOT INITIAL.               CALL FUNCTION 'LXE_OBJ_TEXT_PAIR_WRITE'                 EXPORTING                   t_lang    = ls_tlanguage-o_language                   s_lang    = ls_slanguage-o_language                   custmnr   = ls_objs_colob-custmnr                   objtype   = ls_objs_colob-objtype                   objname   = ls_objs_colob-objname                 TABLES                   lt_pcx_s1 = lt_pcx_s1.
*---------- Create proposal and check status ----------*               LOOP AT lt_pcx_s1 INTO ls_pcx_s1 WHERE t_text IS NOT INITIAL. "#EC CI_NESTED                 CALL FUNCTION 'LXE_PP1_PROPOSAL_EDIT_SE63'                   EXPORTING                     t_lang         = ls_tlanguage-o_language                     s_lang         = ls_slanguage-o_language                     custmnr        = ls_objs_colob-custmnr                     objtype        = ls_objs_colob-objtype                     domatyp        = ls_objs_colob-domatyp                     domanam        = ls_objs_colob-domanam                     pcx_s1         = ls_pcx_s1                     direct_command = 'ASTX'                     direct_status  = '69'.               ENDLOOP.  "Proposal             ENDIF.
*---------- Check and update log translation status ----------*             READ TABLE gt_objects ASSIGNING <ls_object> WITH KEY pgmid    = ls_object-pgmid                                                                  object   = ls_object-object                                                                  obj_name = ls_object-obj_name.             IF sy-subrc IS INITIAL.               CLEAR lv_stattrn.               CALL FUNCTION 'LXE_OBJ_TRANSLATION_STATUS2'                 EXPORTING                   t_lang  = ls_tlanguage-o_language                   s_lang  = ls_slanguage-o_language                   custmnr = ls_objs_colob-custmnr                   objtype = ls_objs_colob-objtype                   objname = ls_objs_colob-objname                 IMPORTING                   stattrn = lv_stattrn.
*---------- Process Translation status ----------*               IF lv_stattrn = 'T'.  "Translated                 IF <ls_object>-statproc <> icon_led_yellow.                   <ls_object>-statproc = icon_led_green.                 ENDIF.               ELSE.                 <ls_object>-statproc = icon_led_yellow.               ENDIF.             ENDIF.           ENDLOOP.  "Target Languagens         ENDLOOP.  "LXE Sub-Objects       ENDLOOP.  "Objects       MESSAGE i398 WITH text-ex1 space space space DISPLAY LIKE 'S'.  "Executed with success     ENDIF.  "Open excel   ENDIF.  "Read excel
ENDFORM.                    " UPLOAD_TEMPLATE
*--------------------------------------------------- Form CREATE_CELL *
FORM create_cell USING p_row_num TYPE i p_cell_num TYPE i p_value TYPE any p_bold TYPE abap_bool               CHANGING c_sheet   TYPE ole2_object.   DATA:     lo_cell TYPE ole2_object,     e_bold  TYPE ole2_object.
*---------- Create Excel cell ----------*   CALL METHOD OF c_sheet 'Cells' = lo_cell  "Get Cell     EXPORTING #1 = p_row_num #2 = p_cell_num.   SET PROPERTY OF lo_cell 'Value' = p_value.                "#EC NOTEXT   IF p_bold IS NOT INITIAL.     GET PROPERTY OF lo_cell 'Font' = e_bold.                "#EC NOTEXT     SET PROPERTY OF e_bold 'Bold' = 1.                      "#EC NOTEXT   ENDIF.
ENDFORM.                    " CREATE_CELL
*---------------------------------- CLASS HANDLE EVENTS IMPLEMENTATION *
CLASS lcl_handle_events IMPLEMENTATION.
*-------------------------------------------------------- User command *   METHOD on_user_command.     CONSTANTS:       lc_copy TYPE string VALUE 'COPY', "Copy original to targets       lc_down TYPE string VALUE 'DOWN', "Download Template       lc_up   TYPE string VALUE 'UP',   "Upload Template       lc_tr   TYPE string VALUE 'TR'.   "Transport request     CHECK e_salv_function = lc_copy OR e_salv_function = lc_down OR           e_salv_function = lc_up   OR e_salv_function = lc_tr.     DATA lr_selections TYPE REF TO cl_salv_selections. "ALV Selections     DATA:       lt_rows    TYPE salv_t_row,            "ALV Rows       ls_row     TYPE i,       lt_objects TYPE TABLE OF gty_objects.  "Objects to translate     DATA lv_answer TYPE c.     FIELD-SYMBOLS <ls_object> LIKE LINE OF gt_objects.  "Objects to translate     TRY.
*---------- Get selected lines ----------*         lr_selections = go_objects->get_selections( ).         lt_rows = lr_selections->get_selected_rows( ).
*---------- Get selected objects ----------*         LOOP AT lt_rows INTO ls_row.           READ TABLE gt_objects ASSIGNING <ls_object> INDEX ls_row.           IF sy-subrc IS INITIAL AND <ls_object>-status = icon_led_green. "Object valid if status OK             CLEAR <ls_object>-statproc.                                   "Clear translation status for reprocessing             APPEND <ls_object> TO lt_objects.                             "Add selected object for processing           ENDIF.         ENDLOOP.         IF lt_objects IS NOT INITIAL. "Objects selected
*---------- Confirmation for copy or update ----------*           IF e_salv_function = lc_copy OR e_salv_function = lc_up.             CALL FUNCTION 'POPUP_TO_CONFIRM'   "#EC FB_RC "#EC CI_SUBRC               EXPORTING                 titlebar       = text-f01                 text_question  = text-f02               IMPORTING                 answer         = lv_answer               EXCEPTIONS                 text_not_found = 1                 OTHERS         = 2.             IF lv_answer <> '1'. RETURN. ENDIF.           ENDIF.
*---------- Execution ----------*           CASE e_salv_function.
*---------- Copy original to targets ----------*             WHEN lc_copy.               PERFORM copy_translations TABLES lt_objects.
*---------- Download Template ----------*             WHEN lc_down.               PERFORM download_template TABLES lt_objects.
*---------- Upload Template ----------*             WHEN lc_up.               PERFORM upload_template TABLES lt_objects.
*---------- Transport request ----------*             WHEN lc_tr.               PERFORM create_transport TABLES lt_objects.           ENDCASE.
*---------- ALV Refresh for copy or update ----------*           IF e_salv_function = lc_copy OR e_salv_function = lc_up.             go_objects->refresh( ).           ENDIF.         ELSE.           MESSAGE i398 WITH text-m04 space space space. "No objects selected         ENDIF.       CATCH cx_root INTO go_exp.                         "#EC CATCH_ALL         gv_msg_text = go_exp->get_text( ).         MESSAGE s398 WITH gv_msg_text space space space DISPLAY LIKE 'E'. "Critical error     ENDTRY.   ENDMETHOD.                    "on_user_command
*-------------------------------------------------------- Line dbclick *   METHOD on_double_click.     DATA:       lt_spopli   TYPE TABLE OF spopli,       "Language infos       ls_spopli   LIKE LINE OF lt_spopli,       ls_language LIKE LINE OF gt_languages,       ls_e071     TYPE e071,                  "Change & Transport System: Object Entries of Requests/Tasks       ls_object   LIKE LINE OF gt_objects.    "Objects to transport     DATA:       lv_answer TYPE c,     "User Answer       lv_tlang  TYPE spras. "Target Translation Language
*---------- Get selected line ----------*     READ TABLE gt_objects INTO ls_object INDEX row.     IF sy-subrc IS INITIAL AND ls_object-status = icon_led_green.       TRY.           IF lines( so_tlang ) = 1. "Only one target language             LOOP AT gt_languages INTO ls_language WHERE laiso <> p_slang.               lv_tlang = ls_language-laiso.               EXIT.             ENDLOOP.           ELSE. "More that one target language
*---------- Fill popup radio buttons ----------*             LOOP AT gt_languages INTO ls_language WHERE laiso <> p_slang.               CONCATENATE ls_language-r3_lang ls_language-text INTO ls_spopli-varoption                 SEPARATED BY space.               APPEND ls_spopli TO lt_spopli.             ENDLOOP.
*---------- Please select target language to Edit ----------*             CALL FUNCTION 'POPUP_TO_DECIDE_LIST'               EXPORTING                 textline1          = text-d01                 titel              = text-d02               IMPORTING                 answer             = lv_answer               TABLES                 t_spopli           = lt_spopli               EXCEPTIONS                 not_enough_answers = 1                 too_much_answers   = 2                 too_much_marks     = 3                 OTHERS             = 4.             IF sy-subrc IS INITIAL AND lv_answer <> 'A'.  "Selected               READ TABLE lt_spopli INTO ls_spopli WITH KEY selflag = abap_true.                   "Get selected radio button               READ TABLE gt_languages INTO ls_language WITH KEY r3_lang = ls_spopli-varoption(2). "Get selected language               lv_tlang = ls_language-laiso.             ENDIF.           ENDIF.
*---------- Edit Target Translation Language ----------*           IF lv_tlang IS NOT INITIAL.             MOVE-CORRESPONDING ls_object TO ls_e071.             CALL FUNCTION 'LXE_OBJ_CALL_WL_SE63'               EXPORTING                 s_lang  = p_slang                 t_lang  = lv_tlang                 do_eval = abap_true                 e071    = ls_e071.           ENDIF.         CATCH cx_root INTO go_exp.                       "#EC CATCH_ALL           gv_msg_text = go_exp->get_text( ).           MESSAGE s398 WITH gv_msg_text space space space DISPLAY LIKE 'E'. "Critical error       ENDTRY.     ENDIF.   ENDMETHOD.                    "on_double_click
ENDCLASS.                    "lcl_handle_events IMPLEMENTATION

Selection screen layout after implementation:

Untitled.png

Result objects list layout:

Untitled.png

Please consider before using:

  • This tool is not full tested and is not possible to ensure that all repository workbench objects can be checked or dependencies and translations detected. Please give feedback if you notice missing objects to be improved;
  • Only objects inside customer scope /0CUST/ are detected and checked. All standard objects are excluded because they are not relevant for transport and translations and performance is significantly improved;
  • ZNM_TRANSLATOR works with most common and used objects. Exotic objects like Sapscript, Smart forms, IDOCs, Workflows and others for the moment are not fully supported;
  • If you are not sure of what you are doing please don't flag overwrite translation option;
  • Please kept in mind that working with excel files and different languages, versions, special characters and data, time or decimal formats can be a problem;
  • You can only include in one transport request objects with green status with a valid development package and belonging to the same target. Objects with yellow status are ignored and not relevant but for red status a manual check is required to avoid transport or translations problems.

How to use:

  • Fill object selection using main objects like Tables, Programs, Classes, Functions Groups, etc to be checked and translated.      

Fill source language and target languages. The tool support more that one target language.

Example of how to check dependencies and translations from EN to PT and FR for program ZNM_TRANSLATOR:

          Untitled.png

  • Double click rows to manual objects translations:

Untitled.png

Because we are translating for more that one target language a popup is raised:

Untitled.png

  • Select lines and execute actions:
    • Untitled.png to download translation template;
    • Untitled.png for automatic translations from excel file template;
    • Untitled.png for automatic copy of source language texts to target languages;
    • Untitled.png to create or add translated objects to transport request.


  • Important status in result objects list:  
    • Check St. indicates that the object dependencies were checked with success and translations exist and can be done;
    • Trans. St. refer to Initial translation status and if green all existent texts are already translated and no action is required;
    • Proc. St. is updated after each user action (copy or upload translations) and indicates the actual translation status:

Untitled.pngAll texts of all target languages are translated;

Untitled.pngTranslations are not full completed, please execute a manual check. 


  • If you are using excel translations file please don't change the columns structure and objects IDs in bold to avoid importation problems:

     Untitled.png


Nuno Morais's Blog

 

Nuno Morais | LinkedIn

How to send email using SAP user id

$
0
0

Emails are not sending out if their SAP user-id is being used as recipient, the email is not present in SOST,
when the direct email address is entered as the recipient address, it can reach the external mail system.

 

As of Basis Release 6.40, we can use transaction SO16 to check and maintain Forwarding/mail system group
addresses on the 'Mail system group' tab page.

If 'No Mail System Group' is set and no autoforwarding setup in SO12, emails won't be sent to external mail system.

 

 

 

 

1. In SO16 -> Tab "Mail sy.grp, Select radiobutton "Send to Home Addresses of User.

 

1.png


2. In transaction SU01, the user must has the email address maintained and have "Email" as the Comm.Method.

 

 

2.png

How to change IDOC SEGMENTS data !!!

$
0
0

Business Requirement:

 

Need to delete the ship-to-party segment data from the inbound IDOC based on some conditions.

1001.jpg

 

 

 

 

 

Analysis:


1002.jpg

 

 

1003.jpg

 

1004.jpg

 

Standard inbound function module IDOC_INPUT_ORDERS is being used to post the IDOC into system.

To fulfill this requirement, we need to enhance the function IDOC_INPUT_ORDERS


Resolution:

1005.jpg


1006.jpg


1007.jpg


CODE SNIPPET:


FORM ZUORDNEN_ORDERS_E1EDKA1.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1 ) Form ZUORDNEN_ORDERS_E1EDKA1, Start                                                                                                          D
*$*$-Start: (1 )--------------------------------------------------------------------------------$*$*
ENHANCEMENT 18  ZLVEDAF5T_ORDERS_IDOC_V1.    "active version
*
DATA: WE_E1EDKA1
TYPE E1EDKA1,
wa_zvari
TYPE zvari,
it_zvari
TYPE STANDARD TABLE OF zvari,
fval
TYPE FIELDVALUE.
DATA: l_t_edidd
like edidd occurs 0,
l_t_edidd_chg
LIKE edidd occurs 0,
l_w_edidd_chg
LIKE edidd.
*  DATA: begin of idoc_contrl_new OCCURS 0.
*          INCLUDE STRUCTURE edidc.
*  DATA: END OF IDOC_CONTRL_NEW.
DATA: idoc_contrl_new
TYPE edidc,
idoc_contrl_new1
TYPE edidc.

*        idoc_status_new TYPE BDIDOCSTAT OCCURS 0 with header line.
DATA:
BEGIN OF IDOC_STATUS_NEW OCCURS 0.
INCLUDE STRUCTURE BDIDOCSTAT.
DATA:
END OF IDOC_STATUS_NEW.
data: L_FLAG
type c.
DATA:
* table of status values
L_STATUS_RECORD 
LIKE  EDI_DS.

FIELD-SYMBOLS: <fs_idoc_data>
TYPE edidd.

CASE E1EDKA1-PARVW.
WHEN 'WE'.
IF e1edka1-name1 IS INITIAL AND e1edka1-name2 IS INITIAL
AND e1edka1-name3 IS INITIAL AND e1edka1-name4 IS INITIAL
AND e1edka1-stras IS INITIAL AND e1edka1-strs2 IS INITIAL
AND e1edka1-pfach IS INITIAL AND e1edka1-ort01 IS INITIAL
AND e1edka1-counc IS INITIAL AND e1edka1-pstlz IS INITIAL.
***Do nothing...
ELSE.
IF NOT E1EDKA1-LIFNR IS INITIAL.
REFRESH: it_zvari.
fval = E1EDKA1-LIFNR.
SELECT * FROM zvari INTO TABLE it_zvari
WHERE programname  EQ 'EDI_ORDERS'
AND fieldname EQ 'MISC_SHIPTO'
AND begda LE sy-datum
AND endda GE sy-datum
AND fieldvalue EQ fval.
IF it_zvari IS INITIAL.
MOVE-CORRESPONDING e1edka1 TO we_e1edka1.
READ TABLE IDOC_DATA ASSIGNING <fs_idoc_data> WITH KEY
segnum = idoc_data-segnum.
IF sy-subrc IS INITIAL.
***Change the IDOC SEGMENT DATA
***Open IDOC for edit
REFRESH: l_t_edidd[].
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_EDIT'
EXPORTING
document_number                     = IDOC_CONTRL-DOCNUM
*                 ALREADY_OPEN                        = 'N'
*               IMPORTING
*                 IDOC_CONTROL                        =
tables
idoc_data                           = L_T_EDIDD[]
EXCEPTIONS
DOCUMENT_FOREIGN_LOCK               =
1
DOCUMENT_NOT_EXIST                  =
2
DOCUMENT_NOT_OPEN                   =
3
STATUS_IS_UNABLE_FOR_CHANGING       =
4
OTHERS                              = 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CLEAR e1edka1.
MOVE: we_e1edka1-parvw
TO e1edka1-parvw,
we_e1edka1-lifnr
TO e1edka1-lifnr.
<fs_idoc_data>-sdata = e1edka1.
CLEAR idoc_data-sdata.
IDOC_DATA-SDATA = E1EDKA1.
l_w_edidd_chg = IDOC_DATA.
***Change segment here
CALL FUNCTION 'EDI_CHANGE_DATA_SEGMENT'
EXPORTING
idoc_changed_data_record       = L_W_EDIDD_CHG
EXCEPTIONS
IDOC_NOT_OPEN                  =
1
DATA_RECORD_NOT_EXIST          =
2
OTHERS                         = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
***Close the IDOC
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_EDIT'
EXPORTING
document_number        = IDOC_CONTRL-DOCNUM
*                 DO_COMMIT              = 'X'
*                 DO_UPDATE              = 'X'
*                 WRITE_ALL_STATUS       = 'X'
*                 STATUS_75              = ' '
*               TABLES
*                 STATUS_RECORDS         =
EXCEPTIONS
IDOC_NOT_OPEN          =
1
DB_ERROR               =
2
OTHERS                 = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

* Write status records..................................................

* create status record
*  L_STATUS_RECORD-DOCNUM = IDOC_CONTRL-DOCNUM.
*  L_STATUS_RECORD-LOGDAT = SY-DATUM.
*  L_STATUS_RECORD-LOGTIM = SY-UZEIT.
*  L_STATUS_RECORD-REPID  = SY-REPID.
*  L_STATUS_RECORD-ROUTID = 'IDOC_STATUS_64OR65_SET'.
*  L_STATUS_RECORD-STATUS = '64'.
*  L_STATUS_RECORD-UNAME  = SY-UNAME.
** fill status fields according to ale service information
*  L_STATUS_RECORD-STAMQU  = 'SAP'.
**  L_STATUS_RECORD-STAMID  = ALE_MESSAGE_IN-MSGID.
**  L_STATUS_RECORD-STATYP  = ALE_MESSAGE_IN-MSGTY.
**  L_STATUS_RECORD-STAMNO  = ALE_MESSAGE_IN-MSGNO.
**  L_STATUS_RECORD-STAPA1  = ALE_MESSAGE_IN-MSGV1.
**  L_STATUS_RECORD-STAPA2  = ALE_MESSAGE_IN-MSGV2.
**  L_STATUS_RECORD-STAPA3  = ALE_MESSAGE_IN-MSGV3.
**  L_STATUS_RECORD-STAPA4  = ALE_MESSAGE_IN-MSGV4.
*
*
** write status record
*  CALL FUNCTION 'EDI_DOCUMENT_STATUS_SET'
*       EXPORTING
*            DOCUMENT_NUMBER         = IDOC_CONTRL-DOCNUM
*            IDOC_STATUS             = L_STATUS_RECORD
*       EXCEPTIONS
*            DOCUMENT_NUMBER_INVALID = 1
*            OTHER_FIELDS_INVALID    = 2
*            STATUS_INVALID          = 3
*            OTHERS                  = 4.


data: L_NO_DB
type c value 'N',
SYNC
TYPE C VALUE 'S'.
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_PROCESS'
EXPORTING
DB_READ_OPTION          = L_NO_DB
DOCUMENT_NUMBER         = idoc_contrl-docnum
ENQUEUE_OPTION          = SYNC
IMPORTING
IDOC_CONTROL            = IDOC_CONTRL_NEW
EXCEPTIONS
DOCUMENT_FOREIGN_LOCK   =
01
DOCUMENT_NOT_EXIST      =
02
DOCUMENT_NUMBER_INVALID =
03
ERROR_MESSAGE           =
04
OTHERS                  = 05.

CLEAR idoc_contrl_new.
REFRESH: idoc_status_new.
idoc_status_new-docnum = idoc_contrl-docnum.
idoc_status_new-status =
'64'.
APPEND idoc_status_new.
L_FLAG =
'X'.
CALL FUNCTION 'IDOC_STATUS_WRITE_TO_DATABASE'
EXPORTING
IDOC_NUMBER      = IDOC_CONTRL-DOCNUM
IDOC_OPENED_FLAG = l_flag
IMPORTING
IDOC_CONTROL     = IDOC_CONTRL_NEW
TABLES
IDOC_STATUS      = IDOC_STATUS_NEW
EXCEPTIONS
IDOC_FOREIGN_LOCK               =
1
IDOC_NOT_FOUND                  =
2
IDOC_STATUS_RECORDS_EMPTY       =
3
IDOC_STATUS_INVALID             =
4
DB_ERROR                        =
5
OTHERS                          = 6 .


IF sy-subrc EQ 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
clear l_flag.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_PROCESS'
EXPORTING
DOCUMENT_NUMBER     = IDOC_CONTRL-DOCNUM
NO_DEQUEUE          = l_flag
IMPORTING
IDOC_CONTROL        = IDOC_CONTRL_NEW
EXCEPTIONS
DOCUMENT_NOT_OPEN   =
01
FAILURE_IN_DB_WRITE =
02
PARAMETER_ERROR     =
03
STATUS_SET_MISSING  =
04.

ENDIF.

ENDIF.
ENDIF.
ENDIF.
ENDIF.
WHEN OTHERS.
***Do nothing...
ENDCASE.
ENDENHANCEMENT.

 

 

CONCLUSION:

 

IDOC Edit Process:

 

EDI_DOCUMENT_OPEN_FOR_EDIT

This function is used to open IDOC segment data in edit mode.

 

EDI_CHANGE_DATA_SEGMENT

We can pass the changed segment data to this function.

 

EDI_DOCUMENT_CLOSE_EDIT

We need to close the editing process of the IDOC segments.

 

After performing above three steps, IDOC status would be 69 (IDOC Was Edited).

 

IDOC Status Change:

 

To post the IDOC in the same LUW, we need to change the IDOC status from 69 to 64. To do this, we should use the below function modules.

 

EDI_DOCUMENT_OPEN_FOR_PROCESS

IDOC_STATUS_WRITE_TO_DATABASE

EDI_DOCUMENT_CLOSE_PROCESS



All the Statuses that IDOC would go through during this process:


1008.jpg

 

Observation:

Status was changed to 69 from 64. This is because we changed the segments data.

Status was changed from 69 to 64. We should change the status to post the IDOC in the same LUW.

 

Hope You have enjoyed this presentation ...

 

Thanks...

Vijaymadhur Papabathini

How to switch between the PC editor and MS editor

$
0
0

In T-cd: I18N or report RSCPINST the below message displayed:

"MS Word is a

default editor now.  Please read SAP Note 742662."

 

When you want to activate/deactivate MS editor please run report
RSCPSETEDITOR in SE38 and press Execute (F8).
On the next screen, when the
checkbox is selected, deselect checkbox SAPScript/ Smartforms and
press
'Activate'. When it is not selected, simply press 'Activate'.

 

You could active the "Sapscript" and "smartforms" as MS editor by "Activate"
button.

Viewing all 935 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>