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

Using BAPI_ALM_ORDER_MAINTAIN to update production order component

$
0
0

As we know that no standard function module or BAPIs released that may be used to change the production order components. Some one suggests to use use BAPI_ALM_ORDER_MAINTAIN to update component.However, note 1275923 inserted a missing validation in the T350 table (order type settings for PM orders) ensuring that this BAPI can no longer be incorrectly used for production orders.

 

Still now we don't find a right way to achieve this requirement, now let me share how to get component by skip this check.


Use implicit enhancement to skip this order type check in FM IBAPI_H_EXEC_BU2_INTERN.

 

Step1 Open FM IBAPI_H_EXEC_BU2_INTERN and Click on Enhance Button

图像 1.png

Step 2 Show implicit Enhancement Options.

图像 2.png

Step 3 Add a new implementation to Skip this FM

图像 4.png

e.g. like this

图像 5.png

 

Use debug to change the value of es_caufvd-auart to ensure the entry is in table T350

图像 6.png

 

Both options are ok.

 

Note 1275923 - BAPI_ALM_ORDER_MAINTAIN: Error message IX019


LSMW for uploading BOM

$
0
0

Purpose

This document will briefly discuss LSMW for uploading Bill of Material using Direct Input Method.

Prepare LSMW

 

Project      : As name describes, I mention the name of the project.
Subproject : I usually maintain the module for which we are preparing.

Object       : It is the business object, in this case I mention as BOM

 

Here I mention LSMW as

L0.JPG

 

One advantage of this kind of naming is, we can see all objects created under one project - under one subproject.L1.JPG

 

Procedure

 

Step 1 : Maintain Object Attributes

L2.JPG

 

 

 

Step 2 : Maintain Source Structures

 

Create two structures, second structure as lower level.

L3.JPG

 

Step 3 : Maintain Source Fields
Here we maintain two structures - one for header level data and second one for item data. Header Material number (MATNR) is the common field connecting these two structures.

 

L4.JPG

 

Step 4 : Maintain Structure Relations

L5.JPG

 

 

Step 5 : Maintain Field Mapping and Conversion Rules

Maintain fields for both the two structures.

L6.JPG

 

 

Step 6 : Prepare Excel File.

Prepare both header and item file separately.

L7.JPG

 

Step 7 : Specify Files

Item file should be created under the Header file.

L8.JPG

 

 

Logical File path must be created in transaction FILE.

 

 

Step 8: Assign Files

L9.JPG

 

Step 9 : Read Data

L10.JPG

 

Step 10 : Display Read Data

Step 11 : Convert Data

Step 12 : Display Converted Data

Step 13 : Create Batch Input Session

L11.JPG

 

Click Display Errors Only

 

Following screen appears .

 

L12.JPG

 

Now the BOM is created for material.

 

L13.JPG

 

 

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

Tip: How to See SAP system/client number in Taskbar

$
0
0

Usually, when we have opened several SAP sessions, it is very difficult to know system/client from the taskbar. Here is how you can configure it to be visible in taskbar:

 

Steps:

  • Open, Windows --> Run, type REGEDIT and enter (click 'Yes' if any pop-up comes)
  • Navigate to this folder: HKEY_CURRENT_USER -> SOFTWARE -> SAP -> SAPGUI Front -> SAP Frontend Server -> Administration
  • Edit the following entry as below: Name: ShowAdditionalTitleInfo, Type REG_DWORD --> Set the value to '1'.

(If this entry does not exist, you can simply create a new entry).

SAP Registry.jpg

 

After this, restart SAP logon, the taskbar should show like this, additional information <system>/<client> is also shown:

SAP Taskbar.jpg

 

Hope it helps many, as it helps me..

Fetch file from presentation server and execute in “Background”.

$
0
0

Hello Friends,

In this tutorial, I am explaining the concept:--            

Fetch file from presentation server and execute in “Background”.

 

Program:--

TYPE-POOLS: slis.

flat file structure*****************
TYPES: BEGIN OF ty_data,
          dealer_code
TYPE kunnr,
          plant
TYPE werks,*          text TYPE sgtxt,
          dr_cr_indicator
(2) TYPE c,
          labr_value
TYPE dmbtr,
          claim_mnth
(2) TYPE c,
          claim_yr
(4) TYPE c,
          cr_note_no
(6) TYPE n,
       
END OF ty_data.
DATA : wa_data TYPE ty_data,
       it_data
TYPE TABLE OF ty_data.
DATA : wa_bapi_data TYPE ty_data,
       it_bapi_data
TYPE TABLE OF ty_data.
TYPES: BEGIN OF ty_final,
        claim_mnth
(2) TYPE c,

        claim_yr(4) TYPE c,

        plant TYPE werks

        labr_value TYPE dmbtr,

        cr_note_no(6) TYPE n,
      
END OF ty_final.

 

***********fetch indexkey table declarion

DATA : exp_data TYPE STANDARD TABLE OF ty_data,
       indxkey
LIKE mcdx-srtfdwa_indx TYPE mcdx.

 

 

DATA:it_final TYPE STANDARD TABLE OF ty_final,
      wa_final
TYPE ty_final.
DATAgs_layout TYPE slis_layout_alv,
       gt_fieldcat
TYPE slis_t_fieldcat_alv,
       gt_events
TYPE slis_t_event,
       g_repid
LIKE sy-repid,
       ls_fieldcat
TYPE slis_fieldcat_alv,
       w_alv_print
TYPE slis_print_alv.DATA: str.
******************************************************************           SELECTION-SCREEN                  ******************************************************************SELECTION-SCREEN BEGIN OF BLOCK b1  WITH FRAME TITLE text-001.SELECTION-SCREEN SKIP 2.PARAMETER p_file TYPE ibipparms-path OBLIGATORY.SELECTION-SCREEN SKIP 2.SELECTION-SCREEN END OF BLOCK b1.
******************************************************************          AT SELECTION-SCREEN                ******************************************************************AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
 
PERFORM file_browse.
 
PERFORM file_upload. " Files into internal table.
AT SELECTION-SCREEN OUTPUT.
 
DATA: exclude LIKE rsexfcode OCCURS 0 WITH HEADER LINE,
        ls_submit_info
TYPE rssubinfo.
******************************************************************          START-OF-SELECTION                 ******************************************************************START-OF-SELECTION.
 
PERFORM process_data.

 
IF it_final[] IS NOT INITIAL.
   
PERFORM alv_display.
   
PERFORM alv_display_fm.
 
ENDIF.

*&---------------------------------------------------------------------**&      Form  FILE_BROWSE*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------**  -->  p1        text*  <--  p2        text*----------------------------------------------------------------------*FORM file_browse .
 
CLEAR p_file.
 
CALL FUNCTION 'F4_FILENAME'
   
IMPORTING
      file_name
= p_file.

ENDFORM.                   

" FILE_BROWSE*&---------------------------------------------------------------------**&     

Form  FILE_UPLOAD*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------**  -->  p1        text*  <--  p2        text*----------------------------------------------------------------------*FORM file_upload .
 
DATA ip_file TYPE string.
 
CLEAR ip_file.
 
REFRESH it_data.
  ip_file
= p_file.
 
CALL FUNCTION 'GUI_UPLOAD'
   
EXPORTING
      filename               
= ip_file
      has_field_separator    
= 'X'
   
TABLES
      data_tab               
= it_data
   
EXCEPTIONS
      file_open_error        
= 1
      file_read_error        
= 2
      no_batch               
= 3
      gui_refuse_filetransfer
= 4
      invalid_type           
= 5
      no_authority           
= 6
      unknown_error          
= 7
      bad_data_format        
= 8
      header_not_allowed     
= 9
      separator_not_allowed  
= 10
      header_too_long        
= 11
      unknown_dp_error       
= 12
      access_denied          
= 13
      dp_out_of_memory       
= 14
      disk_full              
= 15
      dp_timeout             
= 16
     
OTHERS                  = 17.
 
IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 
ENDIF.

 
REFRESH: exp_data.
  exp_data
= it_data.*Index key is group of Report & UserId.
 
CONCATENATE sy-repid sy-uname  INTO indxkey .
 
EXPORT exp_data FROM exp_data
 
TO DATABASE mcdx(zbFROM wa_indx ID indxkey.
ENDFORM.                    "file_upload*&---------------------------------------------------------------------**&      Form  PROCESS_DATA*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*FORM process_data .
 
IF sy-batch EQ 'X'.
   
REFRESH it_data.
   
CONCATENATE sy-repid sy-uname  INTO indxkey .
   
IMPORT exp_data = exp_data  FROM DATABASE mcdx(zb) ID indxkey.
    it_data
= exp_data.
 
ENDIF.
 
IF it_data IS NOT INITIAL.
   
LOOP AT it_data INTO wa_data.
    wa_final
-claim_mnth = wa_data-claim_mnth.
    wa_final
-claim_yr   wa_data-claim_yr.
    wa_final
-plant      wa_data-plant.
    wa_final
-labr_value   wa_data-labr_value.
    wa_final
-cr_note_no       = wa_data-cr_note_no.
   
APPEND wa_final to it_final.
   
ENDLOOP.
 
ELSE.
   
MESSAGE:'No entry found' TYPE 'E'.
 
ENDIF.ENDFORM.                    " FILE_UPLOAD*&---------------------------------------------------------------------**&      Form  ALV_DISPLAY*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------**  -->  p1        text*  <--  p2        text*----------------------------------------------------------------------*FORM alv_display " ankita
 
DATA: col_pos TYPE i.
  col_pos
= 0.

  ls_fieldcat
-fieldname = 'CLAIM_MNTH'.
  ls_fieldcat
-tabname   = 'IT_FINAL'.
  ls_fieldcat
-seltext_l = 'Credit month'.
  ls_fieldcat
-col_pos     = col_pos.

 
APPEND ls_fieldcat TO gt_fieldcat.
 
CLEAR ls_fieldcat.
  col_pos
= col_pos + 1.


  ls_fieldcat
-fieldname = 'CLAIM_YR'.
  ls_fieldcat
-tabname   = 'IT_FINAL'.
  ls_fieldcat
-seltext_l = 'Credit year'.
  ls_fieldcat
-col_pos     = col_pos.

 
APPEND ls_fieldcat TO gt_fieldcat.
 
CLEAR ls_fieldcat.
  col_pos
= col_pos + 1.


  ls_fieldcat
-fieldname = 'PLANT'.
  ls_fieldcat
-tabname   = 'IT_FINAL'.
  ls_fieldcat
-seltext_l = 'Plant'.
  ls_fieldcat
-col_pos     = col_pos.

 
APPEND ls_fieldcat TO gt_fieldcat.
 
CLEAR ls_fieldcat.

  ls_fieldcat
-fieldname = 'CR_NOTE_NO'.
  ls_fieldcat
-tabname   = 'IT_FINAL'.
  ls_fieldcat
-seltext_l = 'credit Not NO'.
  ls_fieldcat
-col_pos     = col_pos.

 
APPEND ls_fieldcat TO gt_fieldcat.
 
CLEAR ls_fieldcat.
ENDFORM.                    " ALV_DISPLAY*&---------------------------------------------------------------------**&      Form  ALV_DISPLAY_FM*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------**  -->  p1        text*  <--  p2        text*----------------------------------------------------------------------*FORM alv_display_fm . " ankita
  g_repid
= sy-repid.

 
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   
EXPORTING
      i_callback_program
= g_repid
      it_fieldcat       
= gt_fieldcat[]
      i_save            
= 'X'
   
TABLES
      t_outtab          
= it_final[]
   
EXCEPTIONS
      program_error     
= 1
     
OTHERS             = 2.
 
IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 
ENDIF.
ENDFORM.                    " ALV_DISPLAY_FM

SPAU - HR Objects

$
0
0

In SAP HR systems,after upgradation through patch levels there are always items in the section :

 

Without Modification Assistant -> HR Objects and there are multiple objects which are shown as yellow.

 

If the objects are adjusted,the changes do not get saved in a transport which is a problem because it has to be done equally in other environments.

 

Solution :

 

SAP has come up with a solution 1875277 - SPAU: HR Objects adjustment which provides resolution to the issue and instead of manually checking individual items in the HR objects,the entire object lists gets activated and saved in a transport.

 

The note desribes about another 634146 which consists of the program RSUMOD_CHECK_NON_TADIR.

Executing the report resolves the issue.

Adding notes, long texts to the Business partner UI

$
0
0

Purpose


The document explains how to load notes in to business partner. The loading is done using a report program. Also there was some requirement to do string operations with the notes from the source system.

 

 

Steps


  1. The source notepad file should contain the Business partner number and note that is to be added.
  2. I am using  FM gui_upload for that.

     Capture.PNG

3.From internal table , now we have the BP number and long text  that is to be loaded. Fill the tables lt_lines as shown below.

 

          Capture.PNG

4.Or you can give lwa_lines-tdformat = '' for better result.

 

5.To run the program ib background , we need to use open dataset.

 

6.We can use the function 'CONV_TEXTSTRING_TO_ITF' for formatting the notes.

 

 

     Capture.PNG

also,

     Capture.PNG

7.Call function Save_text , for populating the text.

 

     Capture.PNG

 

8.Call the BAPI  for saving the text.

 

          Capture.PNG

Material Document List (MB51) Selection Screen Enhancement

$
0
0

Material Document List (MB51) Selection Screen Enhancement


 

Within Inventory Management, the material document list transaction is used to list material documents. It is a very popular transaction.

The selection fields can be changed in configuration.
For example: We want to add the "Order" field to the selection screen.

Selection screen before change

Transaction MB51 - Material Document List
Observation – Current Selection screen has no "Material Document Year" field.

SDN1.JPG
 
Screen after change

Transaction MB51 - Material Document List
This time with the "Material Document Year" field in the selection.

SDN1.JPG


Configuration Required:

Config Menu > Materials Management > Inventory Management > Reporting > Define Field Selection for Material Document List

Or Go-to SM30 and Maintain Table V_MMIM_REP_CUST.

SDN1.JPG

 

 

The above shown example is for existing program/Table/Field, you can also add New Entries as per your requirement.

 

You can also add some fields in output display follow the same steps and check Output option.

 

In case we need to add some fields which are not from table MKPF/ MSEG then use below enhancement spot to add other fields.

 

Enhancement Spot: ES_RM07DOCS

 

Implicit: Add fields in displayed structure near ENHANCEMENT 1 MGV_LAMA_RM07DOCS

 

Explicit:

RM07DOCS_07 Add fields

RM07DOCS_02 Top Include

RM07DOCS_04   Initialization

RM07DOCS_06   Fill added fields value in Loop

 

 

  

Refer below SAP Note for more details:

 

Note 357187 - MB51: Fields in field catalog / selection screen

Note 828104 - Enhancing MB51 for AFS

 

 

Regards,

Sujeet Mishra

Internal Program Environment

$
0
0

Introduction:


Sometimes we get a requirement where we need to do some analysis based on the existing coding. Let’s say we want to replace a SELECT statement in a program with new SELECT or we want to find out the DATABASE Operations happening in a program like MODIFY, UPDATE etc.

In order to find the list of all these things, we can use a facility provided by SAP called “Internal Program Environment”.


Details:

We will take the simple example in order to understand the concept. Create a sample report ZTEST_RM as follows.

3.1.jpg

Now if we want to find out the details in program such as all subroutines, screens, messages, some external objects such as FM’s , Reports, Transaction codes, Some Database operations like SELECT,UPDATE,MODIFY, or some internal table operations like READ,MODIFY. The answer is “Internal Program Environment”.

 

3.2.jpg

3.3.jpg

Since in my report there are no subroutines available, it won’t give any result.

 

3.3.3.png

 

Let’s select the FM and DB operations and see the result.

 

3.4.jpg

3.6.jpg

Please note that this very simple example but in complex scenarios when we have such requirement this utility can be useful.

 

I look forward for your Suggestions/discussions.

 

Thanks for reading!


Using Sets in ABAP Program

$
0
0

Introduction:

Many times we need to maintain some Sets in SAP; normally we use these Sets in Boolean Logic formulas, Report writer, Allocation, Planning, Rollups, and Currency Translation in Financial accounting and controlling Module. But we can also use these basic sets to store some validation related values.

 

Types of Sets:

  1. 1. Basis Sets.
  2. 2. Data Sets.
  3. 3. Single-dimension Sets.
  4. 4. Multi-dimension Sets.

 

Now the purpose of this document is to explain how these Sets are important in ABAP, and how we can access these maintained sets in our ABAP Program.

 

Example:Maintain List of User using sets and check these user details in abap program.

 

Maintaining Sets:

Creation of Sets:

Go to Transaction Code GS01; put your Set name which you want to create. And for the Set we need to maintain Basis data, Click F4 help, then it will ask you for below 3 options.

 

SDN1.JPG

 

Depending on your requirement you can select the table. For example we selected BNAME from USR01 table for user details.

SDN1.JPG

 

Now, we have maintained value as shown in below screen:

SDN1.JPG

All the values maintained against Set are stored in table SETLEAF.

 

Important Transaction Code for Sets:

GS01        Create set

GS02       Change Set

GS03        Display Set

GS04        Delete set

GS07        Exports sets

GS08        Import sets

GS09        Copy sets from client

 

Benefits of Using Sets:

 

In most cases, we create custom table and provide maintenance of the table to store some validation related values. We can maintain those values against a Set. If volumes of values are huge then avoid maintaining it using Sets.

Use sets to maintain TVARV values.

 

Using Sets in ABAP:

Getting all the maintained values against one set.

 

Example:

 

DATA: t_set TYPE TABLE OF rgsb4,
wa_set TYPE rgsb4.
DATA: v_check TYPE C VALUE ' '.

 

  CALL FUNCTION 'G_SET_GET_ALL_VALUES'   

    EXPORTING
client = sy-mandt
  setnr         = 'ZSET'
  table         = 'USR01'
  class         = '0000'
fieldname     = 'BNAME'
TABLES
set_values    = T_SET
EXCEPTIONS
set_not_found = 1
OTHERS = 2.

 

Here, table T_SET contains all the values belonging to SET ‘ZSET’.

 

You can also use the below Function Module to Create/Maintain Sets.

 

Creation of Set using FM.


CALL FUNCTION ‘G_SET_CREATION'

  EXPORTING

set_class                  = '0000'          "Set class

    set_name                 =  ‘ZSET " Set Name (not ID) of Set to be Created

    table =                   " Table for which the Set is to be Created

    types                           =                    " Set Types Allowed (BSMD)

*   field                            = SPACE       "  Field for New Set

*   kokrs =                   " Controlling Area for CO Groups

*   lib                                =                    " Report Library for RW Sets Generated

*   rname                        =                     " Report for Generated RW Sets

*   eccs_dimen              =                     "EC-CS Org. Unit

*   eccs_itclg =                    "EC-CS Chart of Accounts

*   eccs_sityp                 =                     "EC-CS Subitem Category

*   use_group_maintenance =  SPACE  Use Group Maintenance for CO Groups

  IMPORTING

    new_set                     =                      "Set ID (not Name) of the New Set

  EXCEPTIONS

    WRONG_TABLE                           = 1                          

    WRONG_SET_NAME                  = 2          

    NO_SET_CREATED                    = 3

    WRONG_SETCLASS                   = 4          

    SET_ALREADY_EXISTS             = 5      

    WRONG_TYPE = 6              

    WRONG_FIELD = 7             

    NO_FIELD_PICKED                    = 8         

    NO_TYPE_PICKED                     = 9

    GROUP_MAINTENANCE_ERROR = 10  

   

 

Maintenance of Sets:

 

CALL FUNCTION 'G_SET_MAINTENANCE'

  EXPORTING

*   CLASS_MASK                         = ' '

    function                                     =

    set_name_mask                    =

*   TABLE_MASK                         = ' '

*   MASTER_FLAG                        = ' '

*   USE_GROUP_MAINTENANCE         = ' '

*   SHOW_GROUP_VALUE                   = ' '

IMPORTING

*   CLASS                                        =

   SET                                               = 'ZSET'

*   TABLE                                        =

EXCEPTIONS

   ILLEGAL_FUNCTION              = 1

   NO_SETS                                      = 2

   NO_SET_PICKED                      = 3

   SET_NOT_FOUND                      = 4

   NO_AUTHORITY                       = 5

   OBJECT_CREATED_BY_SAP         = 6

   GROUP_MAINTENANCE_ERROR       = 7

   DYNAMIC_SET_ERROR             = 8

   OTHERS                                       = 9

          .

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

 

 

Getting set value using Set IDs:

DATA: w_setid LIKE sethier-setid,
int_vlaues TYPESTANDARDTABLEOF rgsbv.

CALL FUNCTION'G_SET_GET_ID_FROM_NAME'
EXPORTING
shortname     = 'ZSET'       "Set Name
IMPORTING
new_setid     = w_setid
EXCEPTIONS
OTHERS    = 1.

IF sy-subrc NE0.
WRITE'Invalid Set'.
ENDIF.

CALL FUNCTION'G_SET_FETCH'
EXPORTING
setnr              = w_setid
TABLES
set_lines_basic = int_vlaues
EXCEPTIONS
OTHERS          = 1.

 

Reference:

 

http://help.sap.com/saphelp_47x200/helpdata/en/5b/d2297e43c611d182b30000e829fbfe/frameset.htm

How to create custom report symbols in GLM

$
0
0

Step by step guide to create a new custom report symbols in GLM:

 

1. Go to 'SPRO -> SAP Reference IMG ( Press F5 ) -> Environment, Health and Safety -> Basic Data and Tools -> Report Definition -> Report Symbols -> Check and Specify Report Symbols' as shown in the below screenshot. 'Specify Report Symbol Groups' can be used to define the new report symbol groups.

 

SPRO.JPG

 

2. Clicking on the clock near 'Check and Specify Report Symbols' will take us to the below screen. Then click on the 'New Entries' button as shown below to create a new report symbol. Here you can create, change, copy or delete the existing report symbols.

New Ent.JPG

3. Fill the values as shown in the below screenshot:

repsym.JPG

  • Z_HUNUM is the name of the new report symbol.
  • ZGLM_HU is the report symbol group name
  • ZCUST_REP is the table name
  • HUNUM is the field name to which the report symbol is mapped

 

4. Save this entry.

 

5. The structure ZCUST_REP is as shown below:

Struc.JPG

6. The report symbol group 'ZGLM_HU' is as shown below:

Repsymgrp1.JPG

Repsymgrp2.JPG

7. With this we have completed the basic customization for creating a new report symbol. Now we will need to build the custom function module 'ZREP_HANDL_UNIT' defined above to populate the data in our newly created report symbol 'Z_HUNUM'.

 

8. Code below shows how to populate the data in the report symbol 'Z_HUNUM'. Please note that the logic of this function module has been restricted to fetching of the data for only on report symbol. You can extend this FM as per your requirements.

 

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

FUNCTION zrep_handl_unit.

*======================================================================*
* The interface of this custom FM can be copied from any of the standard
* EHS Library Parameter FMs
* I have copied this Interface from the standard EHS FM
* 'CBGL_LB60_PAR_DET_ADDR_SHIP_TO'
* Once we have the interface we can manipulate and populate the data
* for the report symbols belonging to same Report Symbol Group inside
* this Function Module
*======================================================================*
* FUNCTION MODULE ZREP_HANDL_UNIT                                      *
* DESCRIPTION ... Fetching data for report symbol group ZGLM_HU        *
* AUTHOR ........ Vaibhav Shetkar                                      *
*======================================================================*
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(I_FLG_OUT_VALUES) TYPE  ESP1_BOOLEAN DEFAULT ESP1_TRUE
*"     VALUE(I_FLG_IN_VALUES) TYPE  ESP1_BOOLEAN DEFAULT ESP1_TRUE
*"     VALUE(I_VALDAT) TYPE  SY-DATUM DEFAULT SY-DATUM
*"  TABLES
*"      I_CVDDP_TAB STRUCTURE  CVDDP
*"      I_SYMBOL_TAB STRUCTURE  RCGLSTRUCTSYM OPTIONAL
*"      I_SYMBOL_RG_TAB STRUCTURE  RCGLSTRUCTSYM OPTIONAL
*"      I_CVDDP_VALUES_TAB STRUCTURE  CVDDP OPTIONAL
*"      I_CVDDP_VALUES_RG_TAB STRUCTURE  CVDDP OPTIONAL
*"      I_LANGU_TAB TYPE  ESP5_LANGUTAB_TYPE OPTIONAL
*"      E_CVDDP_TAB STRUCTURE  CVDDP
*"      E_CVDDP_RG_TAB STRUCTURE  CVDDP OPTIONAL
*"      E_MESSAGES_TAB STRUCTURE  BALMI OPTIONAL
*"  EXCEPTIONS
*"      INTERNAL_ERROR
*"      OTHERS
*"----------------------------------------------------------------------

* Local Field Symbol declaration
  FIELD-SYMBOLS:
    <ls_symbol>   TYPE rcglstructsym.

* Local Work Area Declaration
  DATA  :   lws_cvddp_tab TYPE  cvddp.

* 'I_SYMBOL_TAB' will have all the data for report symbols belonging
* to the same report symbol group
* In our example it will contain all the report symbols belonging
* to report symbol group 'ZGLM_HU'

* Data reorganisation of symbols and languages
  SORT i_symbol_tab BY lsyid tabname fieldname lsyrpar.
  DELETE ADJACENT DUPLICATES FROM i_symbol_tab
  COMPARING lsyid tabname fieldname lsyrpar.
  DELETE i_langu_tab WHERE langu = '  '.

* Determine data of Handling Unit

* Search for your report symbol here
* I have restricted this looping only for our example
* report symbol 'Z_HUNUM'.
* But we can make use of this loop to populate the data for
* all the report symbols belonging to the same report
* symbol group by modifying the below loop as per your requirement
  LOOP AT i_symbol_tab ASSIGNING <ls_symbol>
    WHERE lsytype EQ '02'                                                  "Report Symbol Type
      AND lsygrp  EQ 'ZGLM_HU'                                           "Report Symbol Group
      AND tabname EQ 'ZCUST_REP'.                                   "Table Name

    CLEAR e_cvddp_tab.

*** If fieldname is 'HUNUM' then we will populate the value
*** in the internal table for report symbol 'Z_HUNUM'
*** Please note that report symbol 'Z_HUNUM' is assigned to the
*** field 'HUNUM' of structure 'ZCUST_REP' in the SPRO settings

    IF <ls_symbol>-fieldname EQ 'HUNUM'.

***   We need to fetch the required value for our
***   report symbol from the available data
***   In my case I have used the already available data to fetch
***   the HU Number value. You might need to write your own logic
***   to fetch the required data as per your requirement.
***   Fetch that necessary data before this loop and use this
***   loop just to populate the data into report symbols
      READ TABLE i_cvddp_tab
          WITH KEY object = '/TDAG/GFS_SYMBOL'
                   attrib = 'HANDLINGUNIT'.
      IF sy-subrc EQ 0.
***     You need to populate the structure name here
***     It should be same as that of 'Table Name' in the SPRO settings
***     for the report symbol
        lws_cvddp_tab-object     = 'ZCUST_REP'.

***     Populate the fieldname here
***     Same as that of 'Field Name' in the SPRO settings
        lws_cvddp_tab-attrib     = 'HUNUM'.

***     Mark this field as 'X'
***     It indicates that this parameter value will be used in the report
        lws_cvddp_tab-repparaflg = 'X'.

***     Assign this as '1' representing the value 'String'
        lws_cvddp_tab-valuetype  = '1'.

***     You need to assign the actual value here in this field
***     This value will be displayed on the label where this
***     report symbol will be used
        lws_cvddp_tab-value      = i_cvddp_tab-value.

***     This field is used to assign the sort sequence
        lws_cvddp_tab-ord        = sy-tabix.

        APPEND lws_cvddp_tab TO e_cvddp_tab.
        CLEAR: lws_cvddp_tab.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDFUNCTION.

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

WE19 - Replicating the IDOCs for analysis

$
0
0

This document deals with replicating the same inbound IDOC data which we want in Quality/Developement to debug or analyse in order to fix the issue with IDOC.

It is never a suggested way to follow ,However during my past experience with projects -it came handy when we were unable to get a proper test data in non production system. It is hard but SAP does have alternate ways which we need to explore.I have seen this idea been shared in some of the discussions but it was never in a detail way and was confusing.Hope this document helps .

 

1.First step is to identify the IDOC which needs to be replicated in non prod system.WE02 will give us a list of IDOCS which can be used to figure out the IDOC in question.

2.Once the IDOC is identified :Go to TCODE - WE19 which is used for testing Inbound idocs.Put the IDOC number from WE02 and ENTER .

    Edit the control record and delete all sender/receiver data ( Port ,partner no, etc).It will help us to avoid reprocessing of production data.

   Test flag checked. Press enter once done.

we19.png

 

3.Now we need to move the IDOC as file which can be done using button "INBOUND FILE" in WE19.Provide the application file server path -Where we need

   to save the idoc data.Most important - Uncheck the check box  "Start IDoc inbound processing of file immediately".and press enter to save the file .

   WE191.png

4.We can copy the file using AL11,CG3Y and CG3Z.Please ensure that you have proper access for copying the file.Else it will throw error.We can use any other alternative way as well to copy the file,

 

5.We need to create a new file port in non production system using WE21.Create a file port TEST and uncheck the 'Unicode FORMAT".Select the FM and

   SAVE.

WE192.png

 

6. WE16  is used replicating the IDOC from application SERVER path where it has been copied. Put the port as TEST .Press enter and it will show successful status message.You can confirm the IDOC is in non production system with the same DATA in WE02.

WE193.png

If we do have any alternative ways of replicating the IDOC without setting up a connection.This can be included in that .

 

Thanks!

Material Master Maintenance without Dialog

$
0
0

Material Master Maintenance without Dialog.


     MATERIAL_MAINTAIN_DARK is used for Material Master Maintenance without Dialog. Which we can in Update mode also.

Before using function module MATERIAL_MAINTAIN_DARK, we need to configure the custom field in SAP IMG.

First add custom field in material master repository, you can create separate sub screen and then assign the sub screen at one particular position.

Follow the below step to maintain the custom field’s sequence in MMR.

sdn1.JPG

 

First add your sub screen to “Define Structure of data Screen ….” Option. And add the screen sequence as per requirement. Example: Screen sequence 21.

 

sdn1.JPG

 

Then go to data screen of same screen sequence and select screen sequence and screen number where you have added customer field.

 

sdn1.JPG

 

Now add custom sub-screen by clicking on.sdn1.JPG

 

sdn1.JPG

Now maintain the custom fields to field selection group which got added in MARC table.

 

sdn1.JPG

 

Once we complete the above steps, we can update the same custom field using function module “MATERIAL_MAINTAIN_DARK”.

 

CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'

EXPORTING

      sperrmodus                = 'E'

      max_errors                =  0

      p_kz_no_warn              = 'E'

      kz_prf                    = ' '

      kz_verw                   = 'X'

      kz_aend                   = 'X'

      user                      = sy-uname

IMPORTING

      number_errors_transaction = lv_count

TABLES

      amara_ueb                 = gt_mara_ueb

      amarc_ueb                 = gt_marc_ueb

      amerrdat                  = gt_amerrdat.

EXCEPTIONS

      kstatus_empty             = 1

      tkstatus_empty            = 2

      t130m_error               = 3

      internal_error            = 4

      too_many_errors           = 5

      update_error              = 6

      OTHERS                    = 7.

 

IF sy-subrc <> 0.

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

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

Endif.

Finding BADI and User exits/Customer exits in a SAP Program

$
0
0

'Finding BADI and User exits/Customer exits in a SAP Program', is a commonplace topic ,but this document is targeted towards the beginners, who find this concept little bit difficult and confusing.

 

It is always tricky to find BADI,user exits etc in a T-code.So here is a simplified generic method to search for it:

 

Finding User exits:

 

The simplest way to find user exits is to search for the string 'User exit' in the main program of the T-code.

For e.g. in the T-code VA01, the user exits can be searched, like:

 

image1.png

image1.png

image1.png

image1.png

  • Usually the User exits are available as FORM-ENDFORM statements, which could be easily implemented by either object key (Source code Modifications) or using the ABAP Implicit Enhancements techniques.

 

Finding Customer Exits

 

There are numerous ways to find the Customer exits.Few good ones are enumerated below:

 

Searching the string ' call*Customer-function* '

 

Search the string *Customer*Exit*  in the main program of the T-code.

 

For e.g. In the T-code VA01/VA03, we can find the following user exits:-

 

 

image1.png

 

 

image1.png

 

 

Now,click on the CALL CUSTOMER-FUNCTION '002',in the code.

 

This wll take you directly to the Function Module of the exit,where the include ZXVVAO04 is available.

Click on this include and the system will prompt you to create the include.Select 'Yes' and the include

is created.Here you can write the logic for the exit.

 

image1.png

image1.png

Using the T-code SMOD/CMOD

 

Another way to search for exits is via the T-code SMOD/CMOD.Here you can search the exits via the Find option.

Path:  SMOD->Utilities->Find

 

image1.png

 

image1.png

Press the execute button and all the exits available in the package are displayed.For advance search, some more parameters like Component Name,Exit name and Application component can also be used.

 

 

image1.png

Via IMG

 

Some exits are also documented in the SAP IMG( Implementation Guide )Tcode -SPRO,which can be implented directly through navigation

 

image1.png

Finding BADI( Business Add-ins)

 

The simplest way to search for BADI is to open the class cl_exithandler in T-code SE24 and put the breakpoint in the static method get_instance;as,

 

image1.png

image1.png

image1.png

Now,Lauch the Transaction VA03

 

image1.png

 

It will launch the debugger automatically,whenever any BADI is encountered.Here the BADI BADI_SD_SALES is triggered.

 

image1.png

Via IMG

 

Some BADI are also documented in the IMG,which can be implemented directly via navigation.

 

image1.png

 

Difference between BADI and User-exit

 

  • An exit can be active in only one project - only one implementation is possible - whereas,A BADI can be implemented multiple times.
  • There are filter dependent BADI's available but no such facilities are available in Exits.
  • There is fixed naming convention in exits , while that is not the case with BADI.

Printing or Downloading Service For Object Attachments to local desktop

$
0
0

Many a times there is a business requirement of linking documents, entering notes, sending notes or linking an internet address to various SAP objects. These external attachments can be reference documents, pictures, Email attachments, designs, diagrams or related spreadsheets. To meet this requirement SAP has provided a tool bar called ‘Generic Object services toolbar’ or ‘GOS toolbar’.

 

For more info on Object Service (Service for objects) refer following link http://scn.sap.com/docs/DOC-33485

 

So, this document demonstrates how to download or print those attachments.

 

Though this Object service toolbar is available for many transactions, in this document I considered to download the attachments of functional locations. In this document I am creating a program which expects Functional Location and Download/Print option (Checkbox) and prints or downloads the Object service attachment of given functional location to a specified path in local desktop as output.

 

* SELECTION-SCREEN
PARAMETERS : P_FUNLOC TYPE ILOA-TPLNR,
              CB_PRVW 
TYPE C AS CHECKBOX.

 

Getting started, Step 1:

 

Get the Spool Requests that are generated by the Active User (user running the program) from the table TSP01 and hold the latest Spool by sorting and reading index 1.

 

TYPES : BEGIN OF LTY_TSP01,
RQIDENT  
TYPE RSPOID,
RQCRETIME
TYPE RSPOCRTIME,
RQFINAL  
TYPE RSPOFINAL,
END OF LTY_TSP01.

DATA : LI_TSP01 TYPE STANDARD TABLE OF LTY_TSP01,
LS_TSP01
TYPE LTY_TSP01.

*START-OF-SELECTION.
START-OF-SELECTION.

SELECT RQIDENT        " Spool request number
RQCRETIME     
" Time a spool request was created
RQFINAL       
" Spool request completed
FROM TSP01
INTO TABLE LI_TSP01
WHERE RQOWNER = SY-UNAME.

IF SY-SUBRC = 0.
SORT LI_TSP01 BY RQCRETIME DESCENDING.
CLEAR: LS_TSP01.

READ TABLE LI_TSP01 INTO LS_TSP01 INDEX 1.

 

 

Step 2:


Now modify the table TSP01 by updating the field - RQPRIO (Spool: Spool or print request priority) to 1 (Very high priority).

 

  IF SY-SUBRC = 0.
UPDATE TSP01
SET RQPRIO = '1'
WHERE RQIDENT = LS_TSP01-RQIDENT.

REFRESH LI_TSP01[].
ENDIF.
ENDIF.

 

 

Step 3:

 

Target any place in the system (desktop/presentation server) and get the list of files present in that directory.

To do so, call method DIRECTORY_LIST_FILES of class CL_GUI_FRONTEND_SERVICES passing directory path and get the count (no.of files exits) and list of files exists in the directory.

 

DATA : file_table TYPE STANDARD TABLE OF file_table,
COUNT      TYPE I,
LV_PATH   
TYPE STRING VALUE 'D:\usr\sap\WCM\Attachments\'.

"GET THE LIST OF FILES
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY                  
= LV_PATH
CHANGING
FILE_TABLE                 
= FILE_TABLE
COUNT                       = COUNT
EXCEPTIONS
CNTL_ERROR                 
= 1
DIRECTORY_LIST_FILES_FAILED
= 2
WRONG_PARAMETER            
= 3
ERROR_NO_GUI               
= 4
NOT_SUPPORTED_BY_GUI       
= 5
OTHERS                      = 6.

 

 

Step 4:

 

If the targeted directory is not empty (contains any files) after calling the above method, delete all those files and make directory empty by calling method FILE_DELETE of class CL_GUI_FRONTEND_SERVICES.

 

DATA : LV_FILENAME TYPE STRING,
RC         
TYPE I,
WA_LIST    
LIKE LINE OF FILE_TABLE.

IF FILE_TABLE[] IS NOT INITIAL.

LOOP AT FILE_TABLE INTO WA_LIST.

CONCATENATE LV_PATH WA_LIST-FILENAME INTO LV_FILENAME.
"DELETE THE EARLIER DOWNLOADED FILES
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
EXPORTING
FILENAME            
= LV_FILENAME
CHANGING
RC                  
= RC
EXCEPTIONS
FILE_DELETE_FAILED  
= 1
CNTL_ERROR          
= 2
ERROR_NO_GUI        
= 3
FILE_NOT_FOUND      
= 4
ACCESS_DENIED       
= 5
UNKNOWN_ERROR       
= 6
NOT_SUPPORTED_BY_GUI
= 7
WRONG_PARAMETER     
= 8
OTHERS               = 9.
CLEAR: LV_FILENAME, RC.
ENDLOOP.
ENDIF.

 

 

Step 5:

 

Now get the Service for Object – Attachments by calling function BDS_GOS_CONNECTIONS_GET by passing the Class name (Business Document Service: Class name), Object key (Structure for Object ID), and client then get the attachments into an internal table.

 

DATA : I_CONNECTIONS TYPE STANDARD TABLE OF BDN_CON INITIAL SIZE 0,
L_OBJKEY     
TYPE SWOTOBJID-OBJKEY.

L_OBJKEY
= P_FUNLOC.

CALL FUNCTION 'BDS_GOS_CONNECTIONS_GET'
EXPORTING
CLASSNAME         
= 'BUS0010'
OBJKEY            
= L_OBJKEY
CLIENT             = SY-MANDT
TABLES
GOS_CONNECTIONS   
= I_CONNECTIONS
EXCEPTIONS
NO_OBJECTS_FOUND  
= 1
INTERNAL_ERROR    
= 2
INTERNAL_GOS_ERROR
= 3
OTHERS             = 4.
IF SY-SUBRC NE 0.
"DO NOTHING
ENDIF.  

 

 

Step 6:

 

Now get the object content by calling Function Module SO_OBJECT_READ by passing the Folder Id and Object Id captured from above function module.

Then download the Object (attachment) into the above targeted folder using function module SO_OBJECT_DOWNLOAD by passing the component Id, Path and object content fetched from above function module.

And also show Preview or directly print as per the user restrictions by calling method EXECUTE of class CL_GUI_FRONTEND_SERVICES by passing path of object and operation (either preview or print).

 

DATA : OBJCONT TYPE STANDARD TABLE OF SOLI INITIAL SIZE 0,
FOL_ID 
TYPE SOODK,
DOC_ID 
TYPE SOODK,

PATH   
TYPE CHAR255,
COMP_ID
TYPE CHAR255,

LV_MIN      
TYPE STRING,
LV_OPERATION
TYPE STRING,
I_PREVIEW   
TYPE TDPREVIEW.

IF CB_PRVW EQ 'X'.
I_PREVIEW
= 'X'.
ELSE.
I_PREVIEW
= SPACE.
ENDIF.

LOOP AT I_CONNECTIONS INTO I_CONNECTIONS_REC .

MOVE I_CONNECTIONS_REC-LOIO_ID TO FOL_ID .
MOVE I_CONNECTIONS_REC-LOIO_ID+17(25) TO DOC_ID .

CALL FUNCTION 'SO_OBJECT_READ'
EXPORTING
FOLDER_ID                 
= FOL_ID
OBJECT_ID                 
= DOC_ID
TABLES
OBJCONT                   
= OBJCONT
EXCEPTIONS
ACTIVE_USER_NOT_EXIST     
= 1
COMMUNICATION_FAILURE     
= 2
COMPONENT_NOT_AVAILABLE   
= 3
FOLDER_NOT_EXIST          
= 4
FOLDER_NO_AUTHORIZATION   
= 5
OBJECT_NOT_EXIST          
= 6
OBJECT_NO_AUTHORIZATION   
= 7
OPERATION_NO_AUTHORIZATION
= 8
OWNER_NOT_EXIST           
= 9
PARAMETER_ERROR           
= 10
SUBSTITUTE_NOT_ACTIVE     
= 11
SUBSTITUTE_NOT_DEFINED    
= 12
SYSTEM_FAILURE            
= 13
X_ERROR                   
= 14
OTHERS                     = 15.
IF SY-SUBRC NE 0.
"DO NOTHING
ENDIF.

CONCATENATE LV_PATH I_CONNECTIONS_REC-DESCRIPT
'.'
I_CONNECTIONS_REC
-DOCUCLASS
INTO PATH.

CONCATENATE I_CONNECTIONS_REC-DESCRIPT
'.'
I_CONNECTIONS_REC
-DOCUCLASS
INTO COMP_ID .

CALL FUNCTION 'SO_OBJECT_DOWNLOAD'
EXPORTING
DEFAULT_FILENAME
= COMP_ID
FILETYPE        
= 'BIN'
PATH_AND_FILE   
= PATH
EXTCT           
= 'K'
NO_DIALOG       
= 'X'
TABLES
OBJCONT         
= OBJCONT
EXCEPTIONS
FILE_WRITE_ERROR
= 1
INVALID_TYPE    
= 2
X_ERROR         
= 3
KPRO_ERROR      
= 4
OTHERS           = 5.
IF SY-SUBRC NE 0.
"DO NOTHING
ENDIF.

LV_FILENAME
= PATH.
IF I_PREVIEW = 'X'.
CLEAR: LV_MIN.
LV_OPERATION
= 'OPEN'.
ELSE.
LV_OPERATION
= 'PRINT'.
LV_MIN
= 'X'.
ENDIF.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
DOCUMENT              
= LV_FILENAME
MINIMIZED             
= LV_MIN
OPERATION             
= LV_OPERATION
EXCEPTIONS
CNTL_ERROR            
= 1
ERROR_NO_GUI          
= 2
BAD_PARAMETER         
= 3
FILE_NOT_FOUND        
= 4
PATH_NOT_FOUND        
= 5
FILE_EXTENSION_UNKNOWN
= 6
ERROR_EXECUTE_FAILED  
= 7
SYNCHRONOUS_FAILED    
= 8
NOT_SUPPORTED_BY_GUI  
= 9
OTHERS                 = 10.
ENDLOOP.

 

 

When I am working on this issue, I came across some documents related to this Service Objects but felt complex. So as I felt this the lesser code to achieve, I wrote this document. Any kind of suggestions or advices are accepted to Improve this.

Hope this will be helpful.

 

Thanks & Regard,

-Vijay

How to set up and run AS ABAP 7.4 trial instances provided as virtual appliance

$
0
0

The following document references the most important guides and tutorials for creating, running and operating the AS ABAP 7.4 trial instances provided as virtual appliances by the SAP Cloud Appliance Library. For questions and feedback regarding these SCN trial editions please post a message in the corresponding ABAP trial thread.

 

Prerequisites

 

 

Tutorials and Guides

 

  • Watch the following video tutorial [5min] to learn how to get and set up an AS ABAP trial instance in your SAP Cloud Appliance Library account:

  • For detailed information about how to set up your local environment and your local clients and how to connect to your ABAP trial instance you can watch the following video tutorial:

 

Frequently Asked Questions

 

Which countries does the SAP Store currently support, in other words grant me access to these trials?

Unfortunately, access to these virtual appliances is limited to all countries supported by the SAP Store. Thus, the currently supported countries are: Australia, Austria, Belgium, Canada, Chile, China, Czech Republic, Denmark, Finland, France, Germany, Greece, Hong Kong, India, Ireland, Isreal, Italy, Japan, Luxembourg, Malaysia, Mexico, Netherlands, New Zealand, Norway, Philippines, Portugal, Romania, Singapore, South Korea, Spain, Sweden, Switzerland, Turkey, United Kingdom, United States, Philippines

 

Is it completely free to use the trial editions of these virtual appliances?

To be precise: SAP offers you to instantiate and run these virtual appliances using the SAP CAL test drive center completely for free (according to the terms and conditions). But you have to pay the charges of your cloud service provider hosting these trial instances (without any involvement of SAP).

 

Do the different trial variants have an impact on the charges of my cloud service provider?

Yes, as an AS ABAP on SAP HANA trial instance requires more virtual CPUs and memory than an AS ABAP on MaxDB trial instance you should use the appropriate instance type/size recommended by the instance creation wizard. This has an impact on the charges of your cloud service provider as shown in the cost forecast of your SAP CAL account.

 

Ok, but how do I find out what my cloud service provider charges for these trial instances?

You have two options:

a) The instance creation wizard of the SAP Cloud Appliance Library offers a detailed cost forecast (you could still cancel the creation process).

b) You can take a look at the Amazon EC2 price list for the recommended instance types: x2.4xlarge (AS ABAP on SAP HANA), m1.large (AS ABAP on SAP MaxDB)

 

So how do I run these trial instances cost-effectively on AWS?

Hosting the trial instances on AWS comprises EC2 services (Elastic Compute Cloud) and EBS services (Elastic Block Store). If you suspend the trial instance there are no costs for EC2 services anymore, but still low costs for EBS services. If you terminate your trial instances, there are also no costs for EBS services anymore. Thus, we recommend to use the 'activate and suspend manually' option, which is part of the instance creation wizard or available within the properties of your existing instance. To be on the safe side, you can also activate a billing alarm in your AWS account.

 

How often do you plan to update the trial editions of these virtual appliances?

We plan to offer a new virtual appliance for every major release and enhancement package of AS ABAP. But we are not going to build and publish new trial appliances for every upcoming support package - maybe some major/important ones.

 

What's the difference between public network access and corporate network access in the instance creation wizard?

In simplified terms, with the public network option you get a public IP address to directly access your trial instance (no VPN required) with all implications on privacy and security. With the corporate network option you get a private IP address from the IP address range of your Virtual Private Cloud. For more information please consult the EC2 user guide.



Read PDF files with Open DataSet(to avoid error corrupted file)

$
0
0

I solved this error today, was looking in the web for this solution and could not find, I just found a lot of people with the same issue, after upload the PDF and try to open in the server or attached the file or sending the file we got an error saying that the file has a error and could not be fixed, the reason is the file size, the open dataset is getting the sy-subrc <> to 0 at the last record and the record is not getting into the table. At the moment to exit we have to append the last row in the table.

 

I hope this help anyone.

 

TYPES: BEGIN OF hex_record,

        field(1024)  TYPE x,

       END OF hex_record.

 

lt_tab_ex2       TYPE STANDARD TABLE OF hex_record WITH HEADER LINE,

 

OPEN DATASET lv_fname FOR INPUT IN BINARY MODE.

      IF SY-subrc EQ 0.

        DO.

          READ DATASET lv_fname INTO lt_tab_ex2-field.

          IF SY-subrc EQ 0.

            append lt_tab_ex2.

          ELSE.

            append lt_tab_ex2.

            EXIT.

          ENDIF.

        ENDDO.

        CLOSE DATASET lv_fname.

How to Upload Long Text into SAP Using Excel Sheet.

$
0
0

Many times user may have requirement during uploading the data into SAP as below points.


  • Upload the Long Text into SAP Using Excel Sheet (i.e. here I am explaining about a PO Text in MM Screen).
  • Long Text Readable within text area no need to use horizontal bar

 

l0.png

Screen Shot # 1

 

 

Solution:

 

  •   Create a Copy of “ALSM_EXCEL_TO_INTERNAL_TABLE” SAP Standard Function Module

           into Custom Function Module “YALSM_EXCEL_TO_INTERNAL_TABLE” .

 

 

L1.png

Screen Shot # 2

 

 

L2.png

Screen Shot # 3

 

 

L3.png

Screen Shot # 4

 

 

 

  •     Custom Upload Program using above Custom Functional Module.

 

 

l4.png

Screen Shot # 5

 

 

L5.png

Screen Shot # 6

 

 

L6.png

Screen Shot # 7

 

 

L7.png

Screen Shot # 8

 

 

L8.png

Screen Shot # 9

 

 

L9.png

Screen Shot # 10

 

 

L10.png

Screen Shot # 11

 

 

L11.png

Screen Shot # 12

 

 

 

  • Output

 

L12.png

Screen Shot # 13

 

 

L13.png

Screen Shot # 14

 

 

l00.png

Screen Shot # 15

 

 

Regard's

Smruti

 

 

 

 


 


Data transfer techniques

$
0
0

Hi,

 

Though there are lots of links and blog are available ,I have written this article .

·         Topics

·         Call transaction

·         Session

·         BAPI

·         Difference between them

·         Recording process.

 

 

 

Hohope this will help the abap developers

 

 

I have screen shots in my documents but i am unable to publish in pdf format how to insert my proper document.

 

Regards,

vanamala kashavena

-------------------------------------------------------------------------------------------------------

 

 

Author: Vanamala Kasheven

Senior ABAP Consultant

This article will give the brief over view of the data transfer techniques present in the SAP and their functionalities,

Also basic steps for recording the tcode and example for call transaction method.

DATA TRANSFER TECHNIQUES

1. BATCH DATA COMMUNICATION:

2. BAPI

3. LSMW

4. IDOC

BATCH DATA COMMUNICATION:

Batch Data Communication or BDC is a batch interfacing technique that SAP developed. It is mainly used for uploading legacy data into the SAP R/3 system.

There are 3 methods in BDC.

 Call transaction

 Session method

 Direct input method

For all the above methods recording is Mandatory. Recording means ruining the tcode with one test data so that we can capture all the required screen details of that tcode by using these screen details we can upload the data into the sap system. Tcode for Recording is SHDB

File types:

 Local files: Files which are stored on desk top on the on the local system.

 Sequential files: Files which are stored on application server.

Prerequisites for any Data Transfer Program:

 Analyzing data from local file: This process involves arranging the data on the file means header details item details, default data etc.., we can take file format in excel, notepad etc..

 Analyzing the transaction: In this we need to see which field are mandatory, which fields we want to pass as by default etc...

Uploading the master data or transactional data into database table of sap system is not done directly; it has to go through the respective Tcode so that the particular record or transaction will be stored in the data base. Going through the transaction code involves recording process that we have discussed above

For example if we are storing the sales order data, we need to record the va01 which is the sales order Tcode. While recording we can see the related tables fields, length of that fields, and also mandatory fields which are the main fields for master data.

There is a structure called BDCDATA provided by sap in this, we can see the fields PROGRAM, DYNPRO, DYNBEGIN, FNAM, and FVAL.

PROGRAM: This field wills holds the module pool program name associated with that screen.

DYNPRO: screen number associated with that module pool programming screen.

DYNBEGIN: Indicates the BDC screen start indicator and set this field to ‘X’ only for the first record ,reset to blank for all the other record.

FNAM: name of the field in the screen

FVAL: value of the field that we are passing this field is case sensitive.

Direct method is no one is using now.

Screen Resolution Problem

In order to avoid this screen resolution problem we use CTU-PARAMS Structure

DISMODE: using this parameter we can decide whether we can handle in all screen mode or error screen mode etc

 A->Display all screens,

 E->Display errors

 N->Background processing

 P->Background processing; debugging possible

UPDMODE: we can in which mode we can update the data in sap database.

 L- >Local

 S- >Synchronous

 A->Asynchronous

CATTMODE: CATT mode (controlling a CATT procedure), The CATT mode can have the following values:

 ' ‘ ->No CATT procedure active

 'N'-> CATT procedure without single screen control

 'A' ->CATT procedure with single screen control

DEFSIZE: setting the screens of the called transaction is displayed in the standard screen size.

 "X" (standard size),

 ‘ ‘ (current size).

RACOMMIT: setting the COMMIT WORK statement terminates batch input processing or not.

 ‘X’->Yes

 ‘ ‘->No

NOBINP: sy-binpt.

 ‘ ’ ->sy-binpt contains in the called transaction "X".

 "X" ->sy-binpt contains in the called transaction ‘ ‘

NOBIEND: sy-binpt

 " " ->sy-binpt contains "X" after the end of the batch input data in the called transaction

 "X" ->sy-binpt contains " " after the end of the batch input data in the called transaction.

Call transaction:

Syntax:

CALL TRANSACTION <TCODE> USING <bdcdata>

MODE <all screens/no screen/error screen>

UPDATE<synchronous/ asynchronous>

MESSAGES INTO <bdcmsgcoll >

If we use the CTU_PARAMS

Syntax:

data: lw_option type ctu_params.

lw_option-dismode = 'E'. lw_option-updmode = 'A'. lw_option-defsize = 'X'. CALL TRANSACTION <TCODE> USING <bdcdata>

OPTIONS FROM <LW_OPTION>

MESSAGES INTO <bdcmsgcoll >.

Synchronous means sy-subrc will be return after all the related tables are get updated, i.e. system will wait until all the tables get updated, and it will always verifies all the data gets updated correctly or not.

Asynchronous means system will not wait until all the tables get updated. It will move on.

 It is compatible for small amount of data

 Using this method we can choose whether we can upload the data in synchronously or asynchronously.

 Error handling is done explicitly by using BDCMSGCOLL structure.

 It can handle only one application at a time

Simple example for call transaction:

In this example I am uploading the data in MK01 tcode.

Recording method:

Tcode for recording is SHDB, Click on new recording button in the shown in the below screen on application tool bar.

Enter the details shown below, and click on start recording button , it will enter in to the MK01 tcode.

As the vendor number creation is set as internal number generation we are I am not filling the vendor value, I have given the Purchasing organization, account group. And press enter, it will enter into the next screen, in the next screen I am filling the title, search term, country language key. And press enter click enter till end and save the tcode

When you click on save u can see this below recording details, then click on save and back.

When you click on the back button u can see below screen with the recorded entry. Select that entry and click on program ,it will create program with the recorded details.

This is the flat file that we want to upload into the sap system using call transaction method

Create program in se38.

I have highlighted the work area fields that I have passed in the recording part to pass the values in to the BDCDATA Structure.

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

*& Include ZFETCHINGLOGIC

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

gf_fpath = pa_fpath.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = gf_fpath

i_begin_col = 1

i_begin_row = 2

i_end_col = 60

i_end_row = 10000

TABLES

intern = gt_excel

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.

LOOP AT gt_excel ASSIGNING <gw_excel>.

CASE <gw_excel>-col.

WHEN '0001'.

gw_mk01-ekorg = <gw_excel>-value.

WHEN '0002'.

gw_mk01-ktokk = <gw_excel>-value.

WHEN '0003'.

gw_mk01-anred = <gw_excel>-value.

WHEN '0004'.

gw_mk01-name1 = <gw_excel>-value.

WHEN '0005'.

gw_mk01-sortl = <gw_excel>-value.

WHEN '0006'.

gw_mk01-land1 = <gw_excel>-value.

WHEN '0007'.

gw_mk01-spras = <gw_excel>-value.

APPEND gw_mk01 TO gT_mk01.

ENDCASE.

ENDLOOP.

LOOP AT gt_mk01 INTO gw_mk01.

*-----------begin of copied code from the recording part--------------------------*

PERFORM bdc_dynpro USING 'SAPMF02K' '0107'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF02K-KTOKK'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RF02K-EKORG' gw_mk01-ekorg.

PERFORM bdc_field USING 'RF02K-KTOKK' gw_mk01-ktokk.

PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-LAND1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'LFA1-ANRED' gw_mk01-anred.

PERFORM bdc_field USING 'LFA1-NAME1' gw_mk01-name1.

PERFORM bdc_field USING 'LFA1-SORTL' gw_mk01-sortl.

PERFORM bdc_field USING 'LFA1-LAND1' gw_mk01-land1.

PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-KUNNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0380'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPDA'.

*---------End of copied code from the recorded program--------------------------------------------------*

CALL TRANSACTION 'MK01' USING gt_bdcdata MODE 'A' UPDATE 'S' MESSAGES INTO gt_bdcmsgcoll.

CLEAR gw_mk01.

REFRESH gt_bdcdata.

ENDLOOP.

LOOP AT gt_bdcmsgcoll ASSIGNING <gw_bdcmsgcoll> .

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = <gw_bdcmsgcoll>-msgid

lang = sy-langu

no = <gw_bdcmsgcoll>-msgnr

v1 = <gw_bdcmsgcoll>-msgv1

v2 = <gw_bdcmsgcoll>-msgv2

v3 = <gw_bdcmsgcoll>-msgv3

v4 = <gw_bdcmsgcoll>-msgv4

IMPORTING

msg = gw_sucess_message

EXCEPTIONS

not_found = 1

OTHERS = 2.

CONCATENATE gw_text <gw_bdcmsgcoll> INTO gw_bdc_error SEPARATED BY space.

APPEND gw_bdc_error TO gt_bdc_error.

ENDLOOP.

LOOP AT gt_bdc_error INTO gw_bdc_error .

WRITE: / gw_bdc_error-text.

ENDLOOP.

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

*& Form BDC_DYNPRO

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

* text

*----------------------------------------------------------------------*

* -->P_0050 text

* -->P_0051 text

*----------------------------------------------------------------------*

FORM bdc_dynpro USING program dynpro.

CLEAR: gw_bdcdata.

gw_bdcdata-program = program.

gw_bdcdata-dynpro = dynpro.

gw_bdcdata-dynbegin = 'X'.

APPEND gw_bdcdata TO gt_bdcdata.

ENDFORM. " BDC_DYNPRO

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

*& Form BDC_FIELD

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

* text

*----------------------------------------------------------------------*

* -->P_0135 text

* -->P_0136 text

*----------------------------------------------------------------------*

FORM bdc_field USING fnam fval.

CLEAR gw_bdcdata.

gw_bdcdata-fnam = fnam.

gw_bdcdata-fval = fval.

CONDENSE gw_bdcdata-fval.

APPEND gw_bdcdata TO gt_bdcdata.

ENDFORM. " BDC_FIELD

*-----------------------------------------------------------------------------------------------------------------------------------------*

Activate the program and run.

Select the excel file saved on the desk top. And execute it.

As we have written the call transaction in all screen mode we can see the creation of the vendor creation with the flat file details.

Now second record

Like that all the record present in the flat file will be up loaded in to the sap.

Session Method:

This method involves 3 function modules

BDC_OPEN_GROUP

BDC_INSERT

BDC_CLOSE_GROUP

 We can use this method for large amount of data

 Data will be uploaded in synchronous and asynchronously.

 Multiple tcode can be handled by using this method

 We can check the session in tcode sm35, here we can process the session.

 In session method data will be store along with screen details

LSMW:

This method is mainly used by functional people and is only for one time process.

BUSINESS APPLICATION PROGRAMMING INTARFACE (BAPI ):

BAPI = (SE37+SWO1)

It is RFC function module.

 In case of enjoy transactions like ME21N the BDC concept will be difficult , these tcodes can be handled by BAPIs

 The main advantage of BAPI is recording is not required.

 Less coding

 It will be protected from version upgrades.

 BAPI structures are frizzed

 Synchronous updating will be done

 Error handling is easy

IDOC:

This method comes under cross applications.

Using this method we can transfer data from sap to sap and sap to non-sap.

IDOC is a 16 digit number. Structure of IDOC contains 3 parts

Control records: It contains the type of IDOC, port of the partner, release of SAP R/3 which produced the IDOC etc

Data record: It will contains the data to be transfer

Status record: It containing the status of the IDOC transfer details like 'IDoc posted or not’, ‘data passed to port’.

Written By:

Vanamala Kashavena

OLE ABAP Code with Password Protected Excel Sheet

$
0
0

Objective


    • Password Store in ‘Y’ Table for the Respective User in Encrypted format .
    • To Export Excel Sheet with Password Protected(i.e. Decrypted format) both Cell and Worksheet.

 

 

  • Upload some User ID’s and it’s respective Password into Custom “Y” table.

 

S1.png

Screen Shot # 0

 

s1_1.png

Screen Shot # 1

 

User Name               : SMRUTI

Encrypted Password: QUJBUEA0MA==

Decrypted Password: ABAP@40

 

 

  • In your Custom Upload Program use below code for Encryption of Password , Which will store in above ‘Y’ Table.

s2.png

Screen Shot # 2

 

Note:

 

PASSWORD    : ABAP@40            ( Decrypted Password )

PASSWORD1  : QUJBUEA0MA== (Encrypted Password )

 

 

  • NowOLE ABAP Code.

 

s3.png

Screen Shot # 3

 

s4.png

Screen Shot # 4

 

 

s5.png

Screen Shot # 5

 

s6.png

Screen Shot # 6

 

 

s7.png

Screen Shot # 7

 

 

s8.png

Screen Shot # 8

 

 

S9.png

Screen Shot # 9

 

S10.png

Screen Shot # 10

 

 

s11.png

Screen Shot # 11

 

 

  • Now Output

 

         Enter your Excel File Name with Path and User Name as a below Screen Shot.

        

        Note: If User Name in Lower Case then Click on Check box


s12.png

Screen Shot #12

 

 

After pressing Execute button or F8 Key you got Exported data( i.e. Password Protected ) in Excel Sheet , look as below Screen Shot .

 

s13.png

Screen Shot # 13

 

 

 

Now Check is your Worksheet, if you want to edit the Cell in work sheet then one password pop window show to ask for password Check below Screen Shot.

Here I want to edit the Division as Per below Screen Shot , then you see one Password Pop-up window appear for asking password , Until Correct Password you unable to edit the data

 

s14.png

Screen Shot # 14

 

 

Now I am try to enter wrong password see below screen shot.


s15.png

Screen Shot # 15


 

Reason of this below OLE ABAP Code line number 131 to 136 .

 

s16.png

Screen Shot # 16

 

 

Then I Enter Correct Password now Check below screen shot and now I am able to edit only where already data are available, mean within Range (i.e. A1:D11)


s17.png

Screen Shot # 17

 

 

Suppose you want add One row in Exported Excel Sheet that also protected by Password, Check below Screen Shot.

 

s18.png

Screen Shot # 18

 

 

Now you Un-Protect the Sheet using Un-protect Sheet in Review (i.e. here I using MS-Excel 2010)

 

s19.png

Screen Shot # 19

 

After pressing above Unprotected Sheet icon, then you pass password for Unprotected the Sheet.

 

S20.png

Screen Shot # 20

 

 

Reason of below OLE ABAP Code.

 

S21.png

Screen Shot # 21

 

 

S22.png

Screen Shot # 22

 

 

 

Note : Here i am using both Cell and Worksheet using one Password (i.e. fetch Encrypted Password from "Y" Table then Decrypt before assign to Excel Sheet ), you can take different password as per your requirement .

 

Regard's

Smruti

 



KO01 Internal Order Screen Enhancement

$
0
0

Internal Order Screen Enhancement: KO01/KO02


This document illustrates the way we can enhance Transaction Code KO01/02 to Create/Change Internal Orders.The below explanation will give you a brief idea to add some fields in Internal Order’s Assignment Tab. As an example we are taking Material Number and Customer Number  fields which we will add in Assignment Tab of Internal table.

Follow the steps below to Add Material Number and Customer Number in Assignment Tab.

 

Go to Transaction Code CMOD and Create Enhancement Project and add Enhancement ‘COOPA003(User-Defined Fields in the Order Master)’ .

 

SDN1.JPG

Click on Component tab as shown in above screen to check all the available components.

Here, we can see Include table CI_AUFK, This is a structure, and we need to create this structure using Transaction Code SE11.

               SDN1.JPG

 

Create structure CI_AUFK and add two fields which we want to add, we added two fields ZZMATNR (Material Number) and ZZKUNNR (Customer Number).

                  SDN1.JPG

 

Once we create above structure, we need to activate this structure CI_AUFK and also re-activate Database view COAS (Order Master for Controlling) & AUFKV (Transfer structure for orders).

 

                SDN1.JPG

                SDN1.JPG

 

 

Now, Go to transaction SE80, and copy few objects of function group KOXM. To function group’ XAUF’.

 

 

 

Object Type

Source(Function Group KOXM)

Target(Function Group XAUF)

Dynpro

SAPLKOXM 0100

SAPLXAUF 0100

Include

LKOXMTOP

ZXAUFTOP

Include

LKOXMF04

ZXAUFU04

Include

LKOXMF05

ZXAUFU05

 

Once we copied the entire above object, we need to activate the same.

 

                    SDN1.JPG

Now Edit the include ZXAUFU04.

  • write imported data in global structures

  MOVE-CORRESPONDING I_AUFK TO GLOBAL_AUFK.

  MOVE-CORRESPONDING I_KAUF TO GLOBAL_KAUF.

  • decide wich subscreen is to be displayed

  IF ( GLOBAL_KAUF-PAR_LAYOU <> 'ABCD' ) AND

     ( GLOBAL_AUFK-AUART  <> '1234' ).

    SUBSCREEN = '0100'.

  ELSE.

    SUBSCREEN = SPACE.

  ENDIF.

And In include ZXAUFU05, add the below code.

 

                   SDN1.JPG

Activate all the include.

Then Go to screen and activate the screen also.

                    SDN1.JPG

 

Once all the object got activated then activate the project.

Now you can have these two fields Material Number and Customer Number in your Internal Order’s Assignment Tab.

Viewing all 935 articles
Browse latest View live


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