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

Animated images in SAP screens

$
0
0

Objective:


To display animated images in SAP screens.


Upload Animated GIF Image in SMWO like this


 

 

 

 

Code:

 


DATA: docking TYPE REF TO cl_gui_docking_container,
v_or_html_viewer
TYPE REF TO cl_gui_html_viewer,
it_query_table
TYPE TABLE OF w3query,
it_html_table 
TYPE TABLE OF w3html,
it_pic_data   
TYPE TABLE OF w3mime,
return_code   
TYPE  w3param-ret_code,
content_type  
TYPE  w3param-cont_type,
content_length
TYPE  w3param-cont_len,
wa_query_table
TYPE w3query,
wa_html_table 
TYPE w3html,
wa_pic_data   
TYPE w3mime,
pic_size      
TYPE i,
url
(256)       TYPE c ,
g_fram
(1255).

PARAMETERS: p_dummy TYPE c  .

AT SELECTION-SCREEN OUTPUT.
PERFORM show_pic.

START-OF-SELECTION.


*&---------------------------------------------------------------------*
*& Form show_pic
*&---------------------------------------------------------------------*
FORM show_pic.

DATA: repid LIKE sy-repid.

repid
= sy-repid.
IF docking IS INITIAL .
CREATE OBJECT docking
EXPORTING
repid
= repid
dynnr
= sy-dynnr
side
= cl_gui_docking_container=>dock_at_right
extension
= '800'
EXCEPTIONS
cntl_error
= 1
cntl_system_error
= 2
create_error
= 3
lifetime_error
= 4
lifetime_dynpro_dynpro_link
= 5.

CREATE OBJECT v_or_html_viewer EXPORTING parent = docking.

CHECK sy-subrc = 0.

REFRESH it_query_table.

wa_query_table
-name = '_OBJECT_ID'.
wa_query_table
-value = 'YIMAGEGIF'.
APPEND wa_query_table TO it_query_table.

CALL FUNCTION 'WWW_GET_MIME_OBJECT'
TABLES
query_string       
= it_query_table
html               
= it_html_table
mime               
= it_pic_data
CHANGING
return_code        
= return_code
content_type       
= content_type
content_length     
= content_length
EXCEPTIONS
object_not_found   
= 1
parameter_not_found
= 2
OTHERS              = 3.
IF sy-subrc = 0.
pic_size
= content_length.
ENDIF.

CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type     = 'IMAGES'
subtype 
= cndp_sap_tab_unknown
size     = pic_size
lifetime
= cndp_lifetime_transaction
TABLES
data     = it_pic_data
CHANGING
url     
= url
EXCEPTIONS
OTHERS   = 1.

* Load the picture by using the url generated by the data provider.
IF sy-subrc = 0.
CALL METHOD v_or_html_viewer->show_url
EXPORTING
url
= url.
ENDIF.
ENDIF .

ENDFORM.                    "show_pic

 

 

Output:

 



Simple Program

$
0
0

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

SELECTION-SCREEN PUSHBUTTON /10(3) push1 USER-COMMAND push1 MODIF ID p1.

SELECTION-SCREEN PUSHBUTTON 14(3)  push2 USER-COMMAND push2 MODIF ID p2.

SELECTION-SCREEN PUSHBUTTON 18(3)  push3 USER-COMMAND push3 MODIF ID p3.

SELECTION-SCREEN PUSHBUTTON /10(3) push4 USER-COMMAND push4 MODIF ID p4.

SELECTION-SCREEN PUSHBUTTON 14(3)  push5 USER-COMMAND push5 MODIF ID p5.

SELECTION-SCREEN PUSHBUTTON 18(3)  push6 USER-COMMAND push6 MODIF ID p6.

SELECTION-SCREEN PUSHBUTTON /10(3) push7 USER-COMMAND push7 MODIF ID p7.

SELECTION-SCREEN PUSHBUTTON 14(3)  push8 USER-COMMAND push8 MODIF ID p8.

SELECTION-SCREEN PUSHBUTTON 18(3)  push9 USER-COMMAND push9 MODIF ID p9.

SELECTION-SCREEN END OF BLOCK b1.

 

DATA       : t_range TYPE RANGE OF char02.

 

PARAMETERS : p_play       TYPE char08 MODIF ID pl.

PARAMETERS : p_result     TYPE char20 MODIF ID rt.

 

DATA       :     v_action TYPE syucomm,

                 v_play   TYPE i,

                 v_won    TYPE char01,

                 v_count  TYPE i.

 

INITIALIZATION.

 

      MOVE :  'PLAYER 1'  TO p_play,

              '1'         TO v_play.

 

AT SELECTION-SCREEN OUTPUT.

 

  PERFORM read_only.

  PERFORM get_event.

 

 

AT SELECTION-SCREEN.

 

  PERFORM get_event_1.

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

*&      Form  GET_EVENT

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

*       Get Events

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

FORM get_event .

 

  CASE v_action.

    WHEN 'PUSH1'.

      PERFORM pass_value.

      PERFORM set_read USING 'P1'.

    WHEN 'PUSH2'.

      PERFORM pass_value.

      PERFORM set_read USING 'P2'.

    WHEN 'PUSH3'.

      PERFORM pass_value.

      PERFORM set_read USING 'P3'.

    WHEN 'PUSH4'.

      PERFORM pass_value.

      PERFORM set_read USING 'P4'.

    WHEN 'PUSH5'.

      PERFORM pass_value.

      PERFORM set_read USING 'P5'.

    WHEN 'PUSH6'.

      PERFORM pass_value.

      PERFORM set_read USING 'P6'.

    WHEN 'PUSH7'.

      PERFORM pass_value.

      PERFORM set_read USING 'P7'.

    WHEN 'PUSH8'.

      PERFORM pass_value.

      PERFORM set_read USING 'P8'.

    WHEN 'PUSH9'.

      PERFORM pass_value.

      PERFORM set_read USING 'P9'.

  ENDCASE.

 

 

  PERFORM check_result USING 'X'.

  PERFORM check_result USING 'O'.

 

ENDFORM.                    " GET_EVENT

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

*&      Form  READ_ONLY

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

*       Inactive element

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

FORM read_only .

  LOOP AT SCREEN.

    CHECK screen-group1 EQ 'PL'.

    screen-input = '0'.

    MODIFY SCREEN.

  ENDLOOP.

 

  LOOP AT SCREEN.

    CHECK screen-group1 EQ 'RT'.

    screen-input = '0'.

    MODIFY SCREEN.

  ENDLOOP.

 

ENDFORM.                    " READ_ONLY

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

*&      Form  SET_READ

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

*       Set Inactive

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

FORM set_read  USING value(p_0128).

 

  DATA : lx_selopt TYPE selopt.

 

  CLEAR lx_selopt.

 

  MOVE : 'I'    TO lx_selopt-sign,

       'EQ'   TO lx_selopt-option,

       p_0128 TO lx_selopt-low.

  APPEND lx_selopt TO t_range.

 

  IF v_play EQ 1.

    ADD 1 TO v_play.

    MOVE : 'PLAYER 2' TO p_play.

  ELSE.

    MOVE 1 TO v_play.

    MOVE : 'PLAYER 1' TO p_play.

  ENDIF.

 

  LOOP AT SCREEN.

    CHECK screen-group1 IN t_range.

    screen-input = '0'.

    MODIFY SCREEN.

  ENDLOOP.

 

ENDFORM.                    " SET_READ

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

*&      Form  GET_EVENT_1

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

*       Action

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

FORM get_event_1 .

 

  CLEAR v_action.

  MOVE sy-ucomm TO v_action.

 

ENDFORM.                    " GET_EVENT_1

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

*&      Form  PASS_VALUE

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

*       Pass Value

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

FORM pass_value.

 

  ADD 1 TO v_count.

 

  CASE v_action.

    WHEN 'PUSH1'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push1.

        WHEN 2.

          MOVE 'O' TO push1.

      ENDCASE.

    WHEN 'PUSH2'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push2.

        WHEN 2.

          MOVE 'O' TO push2.

      ENDCASE.

    WHEN 'PUSH3'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push3.

        WHEN 2.

          MOVE 'O' TO push3.

      ENDCASE.

    WHEN 'PUSH4'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push4.

        WHEN 2.

          MOVE 'O' TO push4.

      ENDCASE.

    WHEN 'PUSH5'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push5.

        WHEN 2.

          MOVE 'O' TO push5.

      ENDCASE.

    WHEN 'PUSH6'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push6.

        WHEN 2.

          MOVE 'O' TO push6.

      ENDCASE.

    WHEN 'PUSH7'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push7.

        WHEN 2.

          MOVE 'O' TO push7.

      ENDCASE.

    WHEN 'PUSH8'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push8.

        WHEN 2.

          MOVE 'O' TO push8.

      ENDCASE.

    WHEN 'PUSH9'.

      CASE v_play.

        WHEN 1.

          MOVE 'X' TO push9.

        WHEN 2.

          MOVE 'O' TO push9.

      ENDCASE.

  ENDCASE.

 

ENDFORM.                    " PASS_VALUE

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

*&      Form  CHECK_RESULT

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

*       Value

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

FORM check_result  USING    value(p_0219).

 

 

  IF push1 = p_0219     AND push2 = p_0219 AND push3 = p_0219.

    MOVE 'X' TO v_won.

  ELSEIF push4 = p_0219 AND push5 = p_0219 AND push6 = p_0219.

    MOVE 'X' TO v_won.

  ELSEIF push7 = p_0219 AND push8 = p_0219 AND push9 = p_0219.

    MOVE 'X' TO v_won.

  ELSEIF push1 = p_0219 AND push4 = p_0219 AND push7 = p_0219.

    MOVE 'X' TO v_won.

  ELSEIF push2 = p_0219 AND push5 = p_0219 AND push8 = p_0219.

    MOVE 'X' TO v_won.

  ELSEIF push3 = p_0219 AND push6 = p_0219 AND push9 = p_0219.

    MOVE 'X' TO v_won.

  ELSEIF push1 = p_0219 AND push5 = p_0219 AND push9 = p_0219.

    MOVE 'X' TO v_won.

  ELSEIF push3 = p_0219 AND push5 = p_0219 AND push7 = p_0219.

    MOVE 'X' TO v_won.

  ENDIF.

 

  IF v_won EQ 'X' AND p_result IS INITIAL.

    CASE p_0219.

      WHEN 'X'.

        MOVE 'PLAYER 1 Won' TO p_result.

        CLEAR p_play.

      WHEN 'O'.

        MOVE 'PLAYER 2 Won' TO p_result.

        CLEAR p_play.

    ENDCASE.

  ELSEIF v_won EQ space AND p_result IS INITIAL AND v_count EQ 9.

    MOVE 'GAME OVER' TO p_result.

    CLEAR p_play.

  ENDIF.

 

ENDFORM.                    " CHECK_RESULT

Traffic Lights

$
0
0


TYPES: BEGIN OF ty_alv,
        lights_1 TYPE icon_d, "Exception, Holding the value of the lights
        lights_2 TYPE icon_d,  "some text
        lights_3 TYPE icon_d,  "some text
*        lights_4 TYPE icon_d,  "some text
       END OF ty_alv.

 

DATA: gs_alv TYPE ty_alv,
      gt_alv TYPE TABLE OF ty_alv,
      gr_alv TYPE REF TO cl_salv_table,
      gr_columns TYPE REF TO cl_salv_columns_table.

 

*-----------------------------------------------*
* CLASS lcl_receiver DEFINITION
*-----------------------------------------------*
*
*-----------------------------------------------*
CLASS lcl_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
    handle_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS.                    "

 

DATA:
i_data TYPE TABLE OF spfli,
o_grid TYPE REF TO cl_gui_alv_grid,
receiver TYPE REF TO lcl_receiver,
timer TYPE REF TO cl_gui_timer.

 

DATA : lv_temp TYPE i.

 

CONSTANTS:
c_interval TYPE i VALUE 1.

 


CREATE OBJECT timer.
CREATE OBJECT receiver.
SET HANDLER receiver->handle_finished FOR timer.
timer->interval = c_interval.
CALL METHOD timer->run.

 


START-OF-SELECTION.

 

  DATA : v_index TYPE index.

 

  DO 33 TIMES.

 

    v_index = sy-index.

 

    IF v_index LE 11.
      MOVE : '@5B@' TO gs_alv-lights_1,
       '@5B@' TO gs_alv-lights_2,
       '@5B@' TO gs_alv-lights_3.
*       '@BZ@'  TO gs_alv-lights_4.
      APPEND gs_alv TO gt_alv.

 

    ELSEIF v_index GT 11 AND v_index LE 22.
      MOVE : '@5D@' TO gs_alv-lights_2,
       '@5D@' TO gs_alv-lights_3,
       '@5D@' TO gs_alv-lights_1.
*       '@BZ@'  TO gs_alv-lights_3.
      APPEND gs_alv TO gt_alv.

 

    ELSEIF v_index GT 22 AND v_index LE 33.
      MOVE : '@5C@' TO gs_alv-lights_3,
       '@5C@' TO gs_alv-lights_1,
       '@5C@' TO gs_alv-lights_2.
*       '@BZ@'  TO gs_alv-lights_2.
      APPEND gs_alv TO gt_alv.
    ENDIF.
  ENDDO.

 

  CALL METHOD cl_salv_table=>factory
*    EXPORTING
*      list_display = 'X'
    IMPORTING
      r_salv_table = gr_alv
    CHANGING
      t_table      = gt_alv.

 

  CALL METHOD gr_alv->refresh.

 

  gr_columns = gr_alv->get_columns( ).

 

*  gr_columns->set_exception_column( value = 'ICON' ).

 


  CALL METHOD gr_alv->display.

 

 

 

*------------------------------------------------*
* CLASS lcl_receiver IMPLEMENTATION
*------------------------------------------------*
*
*------------------------------------------------*
CLASS lcl_receiver IMPLEMENTATION.
  METHOD handle_finished.
    PERFORM refresh_view.
    CALL METHOD timer->run.
  ENDMETHOD.                    "handle_finished
ENDCLASS.                    "lcl_receiver IMPLEMENTATION

 

*&-----------------------------------------------*
*& Form refresh_view
*&-----------------------------------------------*
* Refresh logic
*------------------------------------------------*
FORM refresh_view.

 

  FIELD-SYMBOLS : <lfs_alv> TYPE ty_alv.

 

  DATA : lv_index TYPE sytabix.
  UNASSIGN <lfs_alv>.

 

  DO 11 TIMES.
*    CLEAR lv_index.
*    lv_index = sy-index.
    UNASSIGN <lfs_alv>.
    READ TABLE gt_alv ASSIGNING <lfs_alv> INDEX 1.
    CHECK <lfs_alv> IS ASSIGNED.
    APPEND <lfs_alv> TO gt_alv.
    DELETE gt_alv INDEX 1.
  ENDDO.

 

  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = o_grid.

 

  IF o_grid IS NOT INITIAL.
    CALL METHOD o_grid->refresh_table_display.
  ENDIF.
ENDFORM.                    "refresh_view

Graphical Organizational Structure

$
0
0

In order to display the organizational structure, SAP standard program uses below mentioned Function Module.

 

DATA  lt_object    TYPE STANDARD TABLE OF hrealo.

 

CALL FUNCTION 'PD_STRUCTURAL_GRAPHICS'
     EXPORTING
       context_id                       = 'GENERAL'
       eval_path                         = 'SBESX'
       statuses                            = '1'
       begin_date                      = sy-datum
       end_date                         =  sy-datum
       activate                            = ' '
       load_pd_toolbox            = 'X'
       load_pd_profiles           = 'X'
       callback_program          = 'SAPLRHGB'
       callback_objects            = 'MODIFY_OBJ'
     TABLES
       pd_objects                     = lt_object
     EXCEPTIONS
       no_objects_available = 01.

 


Organizational Structure in a Tree Structure!

$
0
0

Function Module to display the organizational structure in a tree structure.

 

CALL FUNCTION 'RH_ORG_STRUCTURE_SHOW'
       EXPORTING
         act_plvar                    = '01'
         act_otype                   = 'O'
         act_objid                   
'50000001''
         act_begda                  = sy-datum
         act_endda                  = '99991231'
       EXCEPTIONS
         org_unit_not_valid       = 1
         plvar_not_found          = 2
         wegid_not_found        = 3
         structure_error           = 4
         OTHERS                   = 5.
     IF sy-subrc <> 0.
       EXIT.
     ENDIF.

 


Display data with Prefix Zero's in an Excel Sheet

$
0
0

Types : begin of ty_final,

         a type string,

         end of ty_final.

 

data  : b type mara-matnr.

 

data : it_final type TABLE OF ty_final,

        wa_final type ty_final..

 

 

b = '0000147'.

concatenate '=REPLACE("' b '",1,7,"' b '")' into wa_final-a.

append wa_final to it_final.

clear: b, wa_final.

 

b = '0000167'.

concatenate '=REPLACE("' b '",1,7,"' b '")' into wa_final-a.

append wa_final to it_final.

clear: b, wa_final.

 

b = '0000747'.

concatenate '=REPLACE("' b '",1,7,"' b '")' into wa_final-a.

append wa_final to it_final.

clear: b, wa_final.

 

CALL FUNCTION 'GUI_DOWNLOAD'

   EXPORTING

     filename                        = 'd:/excel.xls'

   tables

     data_tab                        = it_final.

           .

IF sy-subrc <> 0.

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

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

ENDIF.

Object Oriented Approach for Dealing Commit Work

$
0
0

This is the question that we should ask,

How to perform dialog processing after commit work execution? 


In general, we may come across the scenario where, some dialog processing needs to be done after transaction “commit work”. It’s explained here by considering a scenario.

After filling all necessary details in the delivery document, user clicks on “save” button to create a delivery document. If any dialog processing (like pop-up to fill some details) required upon successful execution of COMMIT WORK statement. In this case, we can approach below method. 

Let me explain this by creating a custom class.

Create an event handler method in the custom class ZTEST_HANDLER for the event TRANSACTION_FINISHED of the standard class CL_SYSTEM_TRANSACTION_STATE. 

Standard class: CL_SYSTEM_TRANSACTION_STATE

Event name       : TRANSACTION_FINISHED

Note: This event gets triggered as soon as the COMMIT WORK gets executed. 

My custom class name    : ZTEST_HANDLER

My event handler method: CALL_DIALOG (Event TRANSACTION_FINISHED of standard class CL_SYSTEM_TRANSACTION_STATE attached to this custom method) 

1)     Event handler method CALL_DIALOG

http://www.saptechnical.com/Tutorials/OOPS/Dialog/Index.1.jpg

2)     Event handler method: CALL_DIALOG detailed view

http://www.saptechnical.com/Tutorials/OOPS/Dialog/Index.2.jpg

Once the COMMIT WORK for the transaction is executed, control comes to custom method CALL_DIALOG method. Here we can check whether transaction got committed successfully or rolled back by using interface parameter KIND as shown in below screen shot. 

http://www.saptechnical.com/Tutorials/OOPS/Dialog/Index.3.jpg

To get the control to the CALL_DIALOG method, we need to do SET HANDLER to register the event in any user exit before transaction COMMIT WORK execution. 

Here in this case, I registered event in a BADI, which gets triggered after pressing SAVE button in the outbound delivery (VL01N/VL02N) and before COMMIT WORK execution. 

Please find below screen shot of BADI method. 

http://www.saptechnical.com/Tutorials/OOPS/Dialog/Index.4.jpg

The Event TRANANSACTION_FINISHED of standard Class CL_SYSTEM_TRANSACTION_STATE and its parameters are shown in below screen shots:

http://www.saptechnical.com/Tutorials/OOPS/Dialog/Index.5.jpg

http://www.saptechnical.com/Tutorials/OOPS/Dialog/Index.6.jpg

Attributes of Class CL_SYSTEM_TRANSACTION_STATE:


Note: We can use IMPORT and EXPORT statements to transfer data from BADI to the method

http://www.saptechnical.com/Tutorials/OOPS/Dialog/Index.7.jpg

ABAPer's Tabloscope-The SAP Table Relationships & Fields Explorer

$
0
0

Please find as attachment, the source codeand find the user manual(with links to download) below.

 

Note:

  1. Check this document regularly for latest version source code as the functionality of this tool being improved further.
  2. Please, rate this document as it will help others to prioritize this among the other available alternative methods to search relationships, on Google search.

________________________________________________________________________________________________________________________________________

 

SAP is like an ocean and often an ABAP consultant looses much of the time in finding relationships among tables and searching for fields, which causeshim/her miss deadlines. Even SAP quick viewer and other SAP standard search methods doesn't provide him/her with accurate results always and many times they propose very large result set, most of which are irrelevant solutions for the queried scenario. Some problems, an ABAP consultant would usually encounter are:


For example:


1. To search for direct relationships between tables 'EBAN' and 'T16FS', the easy method is to go for SAP Quick Viewer (SQVI). But SQVI shows relationships only if the field names, data elements or domains match. So, in this case it shows only one relationship i.e, between FRGGR fields of both the tables but it doesn't show relationship between fields FRGST and FRGSX of tables EBAN and T16FS respectively which can also be related, as both are ' release strategies'.


2.  To search for indirect relationships (link tables) between two tables in the absence of direct relationships.For example, there are no direct relationships between tables 'VBAK' and 'EKKO' and there is no standard method or tool to find indirect relationships i.e., link tables between them than manually checking, which is cumbersome.

 

3. To search for the field with description 'Bill-to party', one usually goes for 'SE80' which is a case-sensitive search. That is, it would show only those fields with the given description in lower case alphabets when the search term is typed as 'bill-to party'. And most of the times a consultant would be aware of the field description but not the cases of alphabets in field description.

 

4. And moreover, with the usual standard methods an ABAPer uses,the result set would be huge with all SAP tables in which the relevant solutions for our scenario  is somewhere in the remote corner. It's like searching for 'Titanic' in the Atlantic ocean. It would be more easy to search for 'Titanic' if the Atlantic would be of the size of Lake Superior. I.e., It would make the job of an ABAP consultant more easier if the search  can be carried out separately in each module or application area instead of all SAP.


 

                  With one and a half month effort I developed a tool (overcoming all these limitations and adding some more useful functionalities) which I named as 'ABAPer's Tabloscope' can be a very useful assistant especially for an ABAP consultant.

 

                               USER MANUAL

001.jpg

This is cover page, click on any of the links below to download/view complete user manual:

Tabloscope-User Manual.pptx - Google Drive (PPT)

Tabloscope-User Manual.pdf - Google Drive   (PDF)

 



Migrating Selection Screen Variants

$
0
0

In a live SAP system there are lots of report both standard and custom which are run in background.

To run a report in background the first thing that's required is a selection screen variant.

When migrating from one SAP system to another SAP system then these selection screen variants also needs to be copied in the new system.

Creating all the variants of all the programs manually is a very time consuming task.

 

This program is used to copy the selection screen variant for a program between systems.

This is be done as a two stage process.

Firstly the variant from the source system should to be downloaded to a file.

This file is then used in the target system to upload the data from the file and create the variant.

 

The attached files contains the program code and screenshots.

Changing Status Of Transport Released to Modifiable

$
0
0

Hi Guys,

 

This document helps in changing the status of the Request/Task from Released to Modifiable.

 

 

Regards,

Rafi

 

 

1.Go to SE09 transaction and released the

2. Now the TR is released and the same can be seen as below.

 

3 Goto SE38 and run the standard program ‘RDDIT076’ – shown as below

 

4. Provide the TR# as per below screen shot

 

5. We will be able to see the Request / Task as below

 

Here R -> Means Released – we can change it to Modifiable State

Double Click on ‘R’

In the window appeared as below click on ‘Change’ button  and then place cursor in Status field and Press F4 and select ‘D – Modifiable’

Status Pop up

 

After changing status from R to D then save it - Goto SE09 and see the TR - it looks as below with status changed to normal

 

 

Regards,

Mohammed Rafi

Display Background Infomation in Formated ALV Grid

$
0
0

Hello,

 

Sometime because of large data or output users set the program to execute in background process.

 

Once the background job is get completed, they execute the SM37 T-code to view the information, but that information is in list view,

 

their they does not an option like, sorting, filtering and all.

 

It's a program, where user are getting the same functionality, but the output will display in ALV format, there they will get the all necessary option to format the data.

 

Basically the program is created based on the Z* programs, so it will be execute in only for the ALV grid output data.

 

If user does not enter any input, the output will contains the all exist background job information.

 

Basically, user execute the same report with different - different input parameters or job name, that's why based on the above output they can easily find the which date or time information they wants to see.

 

to Display the any of the job output, user need to double click on any of the row.

then the respective job information will display and below.

 

Thanks & regards.

Praveer Kumar Sen.

Single Euro Payments Area (SEPA) Implementation of Direct Debit-Technical Design

$
0
0

Single Euro Payments Area (SEPA) Implementation of DD(Direct Debit)(Technical)

Sep, 2013

Introduction

SEPA stands for ‘Single Euro Payment Area’. It’s a system that is designed to create financial efficiency for countries using the currency Euro by providing a unified system in which to perform financial transactions. The SEPA seeks to create a better system for credit transfers, an improved debit system and a cheaper way for individuals and firms to make transactions within member countries or regions. Implementation of SEPA makes the customers life easier. Irrespective of the national area customers will be able to use the same card for all euro payments and also they need only one bank account in euro area.

Introduction to SEPA process:

The below mentioned should be done for Implementation of SEPA business in any SAP system:

1.    SEPA_Activation_Mandate_Management

Following are the activities which are to be done as part of this:

i.        SEPA mandate management has to be activated for the usage with SDD CORE and SDD B2B from FI-AR payment processing.  Apart from activating the SEPA Mandate management we need to maintain the SEPA Mandate management modifiable fields.

 

Below is the path for activating the SEPA Mandate Management and maintain the modifiable fields.

IMG -> Financial Accounting -> Accounts Receivable and Account Payable -> Business Transactions -> Incoming Payments -> Management of SEPA Mandates -> General Settings.

screen1.png

IMG -> Financial Accounting -> Accounts Receivable and Account Payable -> Business Transactions -> Incoming Payments -> Management of SEPA Mandates -> Define Modifiable Fields

screen2.png                                                                                                                                                                  

ii.        Creation of new DMEE Payment Format tree for SEPA credit transfer and SEPA direct debit.

·         SEPA_CT and SEPA_DD are the DMEE formats provided by SAP.

·         As we will be dealing with multiple countries it is always better to copy the DMEE formats and create new ones. If there is any custom requirement for any country create a user exit and assign to the field that needs to be changed dynamically.

2.  Pre Notification with payment run  :

With a direct debit pre-notification, Markets can inform a payer in writing in advance of the debiting of his account. To do this, one has to schedule a run for the creation of direct debit pre-notifications before the payment run, meaning before clearing the open items and creation of payment media. These correspond in structure to the payment advice notes, and therefore contain details of the run date, the amount to be collected, mandate ID, Unified Creditor Identifier etc.

Following are the SAP notes to be implemented for SEPA Pre-notification.

SAP Note

Description

1679118

F110:  Custom Selection for Batch Input

1760564

F110S:  Selection Check for Customers and Vendors

1770425

F111/SEPA: Mandate rejected as invalid after change

1771071

FBCJ : Reversal possible despite cleared item

1776076

F110/F111 : BADI for SEPA Mandate usage

1780941

SEPA: Direct debit Pre-Notification

1792691

Valid SEPA mandate is not found in the system during payment proposal processing

 

As part of the Note implementation 1780941, we need to implement manual steps given below for importing the Standard SAP Form.

·    SAP has provided text file by using this file we need to import the object F110_DD_PRENOTIF into SAP by executing program RSTXCRP.  This is standard SAP form which will be used for sending PreNotifications.

·    SAP has provided XML file by using this file we need to import the object F110_DD_PRENOTIF into SAP using SFP transaction code. Once it is uploaded, activate the form.

Once all the relevant OSS Notes are implemented for SEPA Direct debit pre-notification, we will get option of checkbox for Pre-notification in F110 transaction and also pre-notification relevant standard program RFFOAVIS_DD_PRENOTIF and script form (F110_DD_PRENOTIF) available in the system.

screen3.png

The above check box is checked if we need to do SEPA prenotification.

screen4.png

 

RFFOAVIS_DD_PRENOTIF: This is the payment advice print program that is used to print the pre-notifications the pre-notification

F110_DD_PRENOTIF: This is the standard SAP script which is used to send the pre-notifications.

scrren61.png

          Based on the user requirement, the form name can be changed

·      The new "direct debit pre-notification" object is visible in the payment run (F110), in the document display (FB03), in the line item display (FBL5N) and in mandate display (FSEPA_M4). It can be deleted again if the direct debit pre-notification customer objects to it (for example, because the customer pays the bill himself). Otherwise, the posting run and the payment medium creation are performed after the end of the specified wait time based on the direct debit pre-notifications.

3.  Creation of SEPA Mandates for payment transactions :

·       Before doing any transaction for any SEPA customer we need to have a mandate create for the Customer.

·       Before creating a mandate the Customer Should have IBAN number.

·       Transactions used :

Creation

FSEPA_M1

Change

FSEPA_M2

Display

FSEPA_M3,FSEPA_M4

NOTE: Mandates can also be created from the payment tab of the Customer Master XD01, FD01, XD02,FD02.

NOTE: Mandate Number can be either External or Internal Number.

·       To make our work easier technically we can use the below procedure using the below BAPI's:

·       The table that is Master for all the SEPA mandates is SEPA_MANDATE.

·       SEPA_MANDATE: This is the Standard Smart form used to print the mandate details for any customer.

·       Assume a file with the Customer and mandate Information is available

Ø  Check if the customer is created by checking in the KNB1 table.

Ø  If the Customer is present then check if the Customer has IBAN and BIC number.

Ø  Check if the mandate is not created for Customer with the mandate number using the BAPI SEPA_MANDATES_API_GET.

Ø  For the BAPI SEPA_MANDATES_API_GET pass the customer number in the importing parameter to check if there is any mandate information present for the Customer SEPA_GET_CRITERIA_MANDATE-snd_id = Customer Number .

screen6.png

Ø  ET_MANDATES contains the mandate information that is fetched from BAPI based on the Customer Number.

scrren71.png

NOTE :   SEPA_MANDATES_API_GET FM cannot be used for multiple mandate scenario. We can write take MGUID from REGUH table and go to SEPA_MANDATE table and get the IBAN number and mandate number.

 

Three BAPI'S are majorly used to Creation and updating of the mandate details of the Customer.

To fetch the Mandate information for a particular Customer from the table SEPA_MANDATE table

SEPA_MANDATES_API_GET

Create the Mandate for a Customer

BAPI_SEPA_MANDATE_CREATE1

Modification of Mandate details for a customer

BAPI_SEPA_MANDATE_CHANGE1

 

·       Mandate Creation:

Ø Use the BAPI BAPI_SEPA_MANDATE_CREATE1 to create the mandate .

Ø BAPI_S_SEPA_MANDATE_COMMON structure which is importing parameter to the above mentioned BAPI has to be filled with the mandate information .This contains both the Sender (Customer Details ) and  receiver details (Company code data ).

screen-8.png

Ø Then collect all the address information either from the file provided or from the customer master data and fill the Sender information in the structure BAPI_S_SEPA_MANDATE_COMMON.

Ø Then based on the company code fetch the address details of the Company code and fill the Receiver information in the structure BAPI_S_SEPA_MANDATE_COMMON.

Ø ES_MANDATE_CREATED exporting parameter in the above BAPI gives a success message if the mandates are correctly created for the customer.

Ø  Error handling can be done with the return exporting parameter.

screen9.png

 

·       If the mandate already exists then check if there is any change in the mandate information.

Mandate modification:

Ø  Use the BAPI BAPI_SEPA_MANDATE_CHANGE1 to change the already existing mandate.

Ø  BAPI_S_SEPA_MANDATE_CHANGE structure which is importing parameter to the above mentioned BAPI has to be filled with the mandate information .This contains both the Sender (Customer Details) and  receiver details (Company code data ).

screen9.png

Ø  In case ofupdation is failed it can handled by  return parameter of the BAPI

screen-10.png

  Display of Mandates :

Ø  The created mandates can be checked by FSEPA_M3 Give the Mandate number or Customer Number and check for the Mandate information.

screen11.png

On Click on Enter the below Screen appears which displays all the information.

screen12.png

 

Ø We can also check the Mandate information through Customer master display  using transaction fd02,xd02,xd03,fd03.screen13.png

Click on the Tab to check and create the mandate Details from Customer master

Display the List of Mandates:

Ø  Use the transaction FSEPA_M4 to display a list for customers for a particular company code.

screen14.png

Ø  Mention the company code in the below transaction and then execute all the mandates present for the company code will be displayed.

Ø  A list of mandates will be displayed as shown in the below screen shot.

screen15.png

The above lights depicts different status of the mandates below are the differnent status of mandates.

0         

Entered

1

Active

2

To Be Confirmed

3

Locked

4

Canceled

5

Obsolete

6

CompletedCompleted

Ø  If we need to print a particular mandate information then select the Print mandate button on the top right corner of the list .

screen16.png

Ø  For this SAP has provided a smartform SEPA_MANDATE.This can be customized at central level and the thus the mandate can be created and mandate information can be printed.

screen17.png

All the inforamtion related to the mandate is available in the table SEPA_MANDATE.

ABAP Dumps

$
0
0

Dumps happen when an ABAP program runs and something goes wrong that cannot be handled by the program. Dumps that happen in the customer namespace ranges (i.e. own-developed code), can usually be fixed by the programmer. Dumps that happen in SAP standard code probably need a fix from SAP.

 

The different sections (in no particular order) and how they help

 

Some of these sections contain useful information, others not. Depending on the exact failure, some sections may contain very little.

 

Short Text

Not much information to be found here, except a brief description of the nature of the cause of the dump.

 

What happened?

Slightly more information.

 

What can you do?

Sometimes there's helpful hints here, most often it's just standard information.

 

Error Analysis

Here is the technical explanation of what went wrong

 

How to correct the error

Hints are given for the keywords that may be used to search on the note system. Various combinations of keywords may be suggested. By using these to search the notes system (formerly known as OSS), you might find a note, or some notes, that fix the problem. For failures in standard SAP objects, this should always be your first port of call in resolving the error.

 

This section may give other hints on resolution, so read carefully.

 

System Environment

This information can be useful for determining the release level. However, for this information, I usually go to System->Status on the failing system. It tells you the SAP release and the Basis support pack level, as well as information about the operating system and hardware.

 

User and Transaction

Information about where the error occurred. The client, the use rid, the language, transaction. the program, screen and screen line number of the failure.

 

Information on where terminated

A little more information about where the program stopped - the function module, for example, the main program, and the exact place in the code that the failure happened.

 

Source Code Extract

Here you can see a portion of the code around the area where the failure happened. If no code can be seen, then usually that indicates an issue at the Basis level. If you click on the code, you are navigated to the editor.

 

Contents of system fields

The values of some of the most important system fields (i.e. the sy- variables) are displayed here. Of particular use are sy-msgno, sy-msgid and sy-msgv1 to sy-msgv4. You can take the values of these and check messages via transaction SE91. In this way you can sometimes find further information about the cause of the error. If you know the message id and message number, you can see what the error text would have been, and in SE91, find the long text of the message. The message id and number is also useful for searching for notes.

 

If you want to debug through to the point of failure, take a note of sy-msgno. Go to a new screen, and type /h to enter the debugger. Then start your transaction, and once you are in ABAP code, create a watchpoint on sy-msgno to stop the debugger at the place where it gets your noted value.

 

Other system fields may also contain useful information.

 

Active Calls/Events

Here you have the call stack - the list of programs / modules / function modules / methods and forms at the time of failure.

 

Chosen variables

A very helpful section. If a dump happens while you are running a transaction on-line, you have the option to enter the debugger, which allows you to check the values of variables. If the dump cannot be reproduced, or occurs only in background, or any other reason, then this section can give very useful hints. The values of variables from each level of the call stack appear here. The size of tables is shown, which can be useful for finding the cause of running out of memory. In later versions of SAP, you can even see the first few entries in tables.

 

Other sections

The remaining sections I have not found to be particularly useful for the ABAP developer, though they may be extremely interesting for SAP or Basis consultants. I shall not describe these sections.

 

Notes on different kinds of dump

 

As I come across new situations, I shall add to this document from time to time.

 

RAISE_EXCEPTION

A function module raise an exception that was not intercepted by a program higher up in the stack. If this occurs in a customer program, then the developer needs to handle the exception in the calling program. If it happens in a SAP program, then it may be an unexpected situation. It is often useful for this kind of failure to look at the values of sy-msgid and sy-msgno. You should also search for notes containing the message id and number, and/or important keywords from the "How to correct the error" section.

 

RFC_ATTACH_GUI_FAILED

This commonly happens when an RFC enabled function module is run, that then goes on to do something connected with screen handling. As it does not have a screen, it fails. It can also happen if SAPGui (or components of it, such a BEX) have a problem, or are incorrectly installed.

 

LOAD_PROGRAM_LOST

The program you were running was changed while you were running it. In a BI (and other similar environments) this happens quite often if you are in sections of the system that generate code - such as developing routines in transformations. There is not much to do but restart the transaction you were running. To avoid this in RSA1, if you are doing lots of complicated development, it is a good idea to restart the transaction from time to time.

 

DBIF_RSQL_SQL_ERROR

Indicates a problem occurred in the database. You may find more information in the system log via SM21. The exact nature of the failure is usually seen in the "How to correct the error" section. If this occurs in standard SAP code, then there may be a corrective note. It may be connected with database set up, so if the cause is not obvious (like a malformed dynamic SQL from one of your own programs), it may be worth talking to your basis team.

 

MESSAGE_TYPE_X

If this message comes up, it means the program met a situation that it just did not know what to do with. In the "Error Analysis" section you will see the short and long text of the error message. Sometimes the error indicates inconsistent data, sometimes as Rob Dielemans points out, it can be used deliberately during the development process.

 

If, during development you simply want to know if a certain piece of code gets executed at all (usually background stuff, like workflow ), you just code a type X message with some values such as sy-uname, or other variable you are interested in. This is a very good way to exactly find out the value of a parameter when differences can occur in debugging.

 

ASSIGN_TYPE_CONFLICT

Most likely a programming error. This message indicates that an ASSIGN is occurring that is going to an incorrectly typed field-symbol. Check the Source Code Extract to see exactly where the problem occurs, and carefully check that the typing of the object matches.

 

OBJECTS_OBJREF_NOT_ASSIGNED_NO

An attempt was made to access an object (the class type is given), that had not been instantiated. Most likely a programming error.

 

TSV_TNEW_PAGE_ALLOC_FAILED

This indicates that your process ran out of memory. This may be a programming issue - check the size of internal tables. Perhaps there is an eternal loop that just keeps adding to a table. It may be a hardware issue - that there simply isn't enough memory available. This type of error can be hard to track down, as the place where memory is actually exhausted may vary. "What can you do" shows the amount of memory of the various kinds that were available. There may be information in the "Error analysis" section that shows exactly which internal table could no longer be stretched to contain more data.

 

UNCAUGHT_EXCEPTION

This is the object oriented equivalent of RAISE_EXCEPTION. It means that a class-based exception was raised in a method / function module / form that was not caught higher up. Usually this indicates a programming error. I've seen attempts to fix this, using CATCH cx_root, and then continuing processing. This is a very bad way of fixing the error, as it just ignores the cause of the exception. Ignoring an exception like this is like ignoring non-zero sy-subrc.

 

COMPUTE_INT_ZERODIVIDE

Exactly what it says - an attempt has been made to divide by zero. This is either a data or programming error. In fact, it's always a programming error as any division should always check if the denominator is zero, and correct raise an error condition if it is.

 

RFC_NO_AUTHORITY

Simple one this. The user that tried to execute an RFC enabled function module, via RFC, was not authorised via authorisation object S_RFC to run the function module. The name of the function module is in the Short Text. The name of the user id is in the "What happened?" section.

 

TIME_OUT

There is a Basis setting that sets a limit for the run time of a transaction or report- typically fifteen minutes. If a dialogue process exceeds this limit, the kernel spots it and stops the program with a TIME_OUT dump. Common causes are:

  • User selecting too much data - like all companies, or all controlling areas.
  • A programming error resulting in a endless loop
  • Inefficient programming. For example, using STANDARD tables instead of HASHED or SORTED, loops within loops, selecting the same data again and again etc.

The common solution is to extended the allowed run time. However, this should be the very last resort, as it only fixes the symptom, not the root cause, and, as data volumes increase, you are likely to hit the new limit eventually. It is much better to fix the program. Where users select too much data, for example, the selection screen can be adjusted to prevent this. If a wide selection is needed, perhaps the program can be run in background - and if necessary, populate a database table that can be reported on.

Email Sending Functionality for Different Business Process in Sap

$
0
0

Email Sending Functionality for Different Business Process in Sap

Nov, 2013

 

 

Introduction

Every Business Process in SAP Follow different communication types to communicate with its Business partners like Print and send via post, Fax, and Email (Internet).Several E-mail communications need to be sent to Vendors & Customers who are the business partners for the organization which contains several Business Processes like Payment Advice, Dunning forms and PO’s etc., with PDF and Excel as attachment, which is a very eco-friendly way. Presently many are using the process of taking a print out and sending it through the post. This Process has lot of paper wastage. So instead of this we can send a mail which saves lot of paper wastage .This process enables the Go green Initiative and reduces lot of manual effort. With the recent releases in SAP all the Business process are enhanced with Email sending functionality.

Introduction to Email Processes

Every Standard FI process like Dunning and Payment and collection advice has a default way of sending there notices to the customer or vendor by post. Sending a mail is not a standard SAP functionality; in order to achieve this nonstandard Functionality we have BTE.  This is an enhancement technique (Open FI) that was developed for Financial Accounting component. This functionality is primarily used in FI in the areas of dunning, Payment advice Customer and Vendor Statement etc. Each of them has their own Function modules which will not interfere with each other.

           Each of these has a BTE’s enabled to fill the FINNA-NACHA structure to determine whether the output should be sent as fax, print via post or email, i.e., if FINAA-NACHA = 1 - print via post and FINAA-NACHA = ‘I’ its email and if its ‘2’ FAX.

This Document contains how this mail functionality can be achieved by using the BTE’s for Different applications in FI.

1. Application Area: FI - Accounts payable and Accounts receivable – Dunning

     Application of the process BTE event '00001040' -

· This process BTE is useful during a dunning run when a dunning notice needs to be sent to the customer by the medium of an electronic form (EMAIL).
As a default property, the dunning notice gets printed and is sent to the customer either by scanning the copy or via 'POST'.

· This same dunning notice could be a very beneficial if it is sent by means of electronic form directly after the dunning has been carried out.

· So, to achieve this non-standard functionality we need to enhance the standard process.

      Transaction - FIBF -> Environment -> Info systems (Processes)

· Click on execute,

 

· Select the BTE 00001040 as it deals with the Output device/medium

Fig1.jpg

· Change the Already Present function module to Z function Module.

fig2.jpg

Now, technically the BTE is ready to work as we have registered the BTE.

As a functional aspect, the following things are needed to be taken care of.

· Standard communication option - to 'EMAIL' in the 'General' Tab in customer master 'XD02/01'.

fig3.jpg

· After configuring these basic steps, the BTE is complete to trigger for dunning run for this particular customer.

     Dunning Run

· SAPF150D2-This Program can be used to execute the Dunning form by giving the Run date and identification and the logic in the FM's can be checked by placing the debugger.

· Best way is to check in the debugger,

fig4.jpg

Ø  FINAA-NACHA - For Communication Medium (I- Internet, 1-Print Out, 2-Fax)

Ø  FINAA_INTAD – Email Address to send the PDF

 

Fig5.jpg

Ø Process the next step by confirming the 'Send to mail' dialog,

Ø If 'C_FINAA-INTAD' is left blank the system will pick from the customer master 'Clerks internet', else it will take from the value 'C_FINAA-INTAD'. This enables the PDF sending functionality which enables is standard process and the logic to send excel can be written in the above FM only. Also if you need to fill the Subject of Email use itcpo-tdtitle structure which of 50 characters. If we need to send the Body also Maintain the standard text as mentioned in the below screen shot.

fig6.jpg

NOTE: If we need to send many attachments other than PDF we have to write the code in the above FM call the common mail sending functionality. In this case first a mail will be sent with Excel or some other as attachment then the standard PDF functionality is called.

This is a very eco-friendly means of informing the customers for their over-due items.

 

 

2. Application Area: FI – Payment Advice and Collection Advice:

     Application of the process BTE event '00002040' –

This BTE is called in the standard include RFFORI06 as shown below.

fig7.png

· In the transaction FIBF Select the BTE 00002040 as it deals with the Output device/medium sample_process_00002040 will be assigned.

 

· Since this is not a standard functionality we need to enhance the FM so copy the

sample_process_00002040 into Zsample_process_00002040.

Logic in the FM

Check if customer or Vendor has Email Maintained in the Master Data. If it’s maintained then

· The structure c_finna included the internet address.

          We set the transmission medium to ‘I’ as below.

          c_finaa-nacha = 'I'.

          c_finaa-intad = l_smtp_addr(130). [The email Obtained from the master data]

·    Later the mail sending functionality can be called after the close_form as shown in the below screen shot or By OTF data and excel can be created using the tab_regup structure in the   form avis_schreiben.

3. Application Area: FI – Customer/Vendor Balance Confirmation:

     Application of the process BTE event '00002410' –

· This process BTE is useful during a Customer/Vendor Balance Confirmation form which needs to be sent to the Customer/Vendor by an electronic form (EMAIL). By default, the form is sent to the Customer/Vendor either by Fax or via 'POST'.

· But as an environmental aspect to avoid wastage of paper, the same Statement could be sent by means of electronic form directly after the Customer/Vendor Statement run has been carried out.

· So, to achieve this functionality we need to enhance the standard process.

     Transaction - FIBF -> Environment -> Info Systems (Processes)

· Click on Execute.

· Select BTE 00002410 as it deals with Determining the Output Device

fig8.png

· Click on Sample Function Module. The FM 'SAMPLE_PROCESS_00002410' is assigned. In order to include the mail sending functionality, Copy the Function Module into a Z Function Module and make the required changes to enable the mail sending functionality.

     Logic in the FM:

Check if the Customer or Vendor has Email Maintained in the Master Data. If it is maintained then

· The structure c_finna includes the internet address.

We set the transmission medium to ‘I’ as below.

          C_finaa-nacha = 'I'.

         C_finaa-intad = l_smtp_addr(130). [Email Obtained from the master data]

· Later the mail sending functionality can be called after the Close_form as shown in the below screen shot or By OTF data, and excel can be created using the Structure HBSIDH for Customer and HBSIKH for Vendor.

Fig9.png

4. How to achieve Mail Functionality Technically:

Create a Common Functionality for sending mail using classes

i) For sending the subject greater than 255 characters   

· At present using the FM SO_DOCUMENT_SEND_API1 has the capability of sending only 50 characters but using the below method of the class the subject more than 255 characters.

· So cl_bcs class is used for the below purpose.

· There is also any option of changing the sender ID in case the requirement is not    to use the           

· SAP master User ID using the cl_bcs  class.

· Create the below object of type cl_bcs  and call the method  set_message_subject        

          w_send_request     TYPE REF TO cl_bcs           VALUE IS INITIAL,      
     
CALL METHOD w_send_request->set_message_subject
       
EXPORTING
          ip_subject = subject.

ii) For Sending Multiple Attachments like PDF and Excel

· In case multiple attachments the below method add_attachment attachment can be used by looping on the attachments obtained to this function module.

     f_ATTACHMENTS    TYPE      RMPS_T_POST_CONTENT

      w_document       TYPE REF TO cl_document_bcs  VALUE IS INITIAL,

     
LOOP AT attachments INTO f_attachment.


        w_attachment_subject = f_attachment-subject.
        w_filesize = f_attachment-docsize.

· This Method will have the option to take input as method subject, filesize and
        w_document->add_attachment(
       
EXPORTING
        i_attachment_type    = f_attachment-doc_type
        i_attachment_subject = w_attachment_subject
        i_attachment_size    = w_filesize
        i_att_content_text   = f_attachment-cont_text[] ).

      ENDLOOP.

    iii) For Sending Email to multiple recipients like To, BCC and CC,

· The below Logic can applied to provide cc bcc and to as like multiple receivers. The method

add_recipient   has the option to give blind_copy, Copy and recipient.

w_recipient      TYPE REF TO if_recipient_bcs VALUE IS INITIAL,

· Loop at the multiple receivers

LOOP AT receivers INTO f_receivers.

          w_recipient_mail = f_receivers-receiver .

· The below method sets them mail ID of the Receiver.
          w_recipient = cl_
cam_address_bcs=>create_internet_address(
                         w_recipient_mail).

        w_send_request->add_recipient(
           
EXPORTING
            i_recipient = w_recipient
            i_express =
'X'
            i_copy = f_receivers-copy
            i_blind_copy = f_receivers-blind_copy).
ENDLOOP.

Featured Content for ABAP Development

$
0
0

SQL Monitor Unleashed

Have you heard about the SQL Monitor already? It can be used to detect custom code which can be optimized (in the context of the migration to SAP HANA, but also independent of that). If you like to learn more, read Johannes Marbach's blog series. You find the first blog here.November 18, 2013

 

Optimizing custom ABAP Code for SAP HANA

Where do you want to start a custom code SQL performance analysis seeing countless SQL requests? Exactly this question can now be answered using the new ABAP SQL monitor. For more information about the ABAP SQL monitor please consult the corresponding guide by Boris Gebhardt.October 11, 2013

 

Considerations for Custom ABAP Code During a Migration to SAP HANA

Considering a migration of your custom code to an AS ABAP 7.4 on SAP HANA system? Then you should read this best practice guide by Eric Westenberger containing important considerations and recommendations. Moreover, this document provides an overview of the available tools and services which can ease a transition of custom ABAP code, and gives guidance how to use them.September 27, 2013

 

SCN Trial Editions of SAP NetWeaver Application Server ABAP 7.4

Get your hands on SAP NetWeaver Application Server ABAP 7.4 on SAP HANA or SAP MaxDB and learn more about its new capabilities and the programming language enhancements! Visit this page to learn more about the new ABAP trials provided as virtual appliances by the SAP Cloud Appliance Library.July 24, 2013

 


Program to find User Exits for standard T-Code

$
0
0

REPORT  ZUSEREXIT.

******TABLES USED*******

TABLES : TSTC, TSTCT, TADIR, MODSAPT, MODACT, TRDIR, TFDIR, ENLFDIR.

DATA : JTAB LIKE TADIR OCCURS 0 WITH HEADER LINE.

DATA : FIELD1(30).

DATA : V_DEVCLASS LIKE TADIR-DEVCLASS.


PARAMETERS : P_TCODE LIKE TSTC-TCODE OBLIGATORY.

 

SELECT SINGLE * FROM TSTC WHERE TCODE EQ P_TCODE.

IF SY-SUBRC EQ 0.

   SELECT SINGLE * FROM TADIR WHERE PGMID = 'R3TR'

                    AND OBJECT = 'PROG'

                    AND OBJ_NAME = TSTC-PGMNA.

   MOVE : TADIR-DEVCLASS TO V_DEVCLASS.

      IF SY-SUBRC NE 0.

         SELECT SINGLE * FROM TRDIR WHERE NAME = TSTC-PGMNA.

         IF TRDIR-SUBC EQ 'F'.

            SELECT SINGLE * FROM TFDIR WHERE PNAME = TSTC-PGMNA.

            SELECT SINGLE * FROM ENLFDIR WHERE FUNCNAME =

            TFDIR-FUNCNAME.

            SELECT SINGLE * FROM TADIR WHERE PGMID = 'R3TR'

                               AND OBJECT = 'FUGR'

                               AND OBJ_NAME EQ ENLFDIR-AREA.

 

            MOVE : TADIR-DEVCLASS TO V_DEVCLASS.

          ENDIF.

       ENDIF.

       SELECT * FROM TADIR INTO TABLE JTAB

                     WHERE PGMID = 'R3TR'

                       AND OBJECT = 'SMOD'

                       AND DEVCLASS = V_DEVCLASS.

        SELECT SINGLE * FROM TSTCT WHERE SPRSL EQ SY-LANGU AND

                                         TCODE EQ P_TCODE.

        FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.

        WRITE:/(19) 'TRANSACTION CODE - ',20(20) P_TCODE,45(50) TSTCT-TTEXT.


        SKIP.


        IF NOT JTAB[] IS INITIAL.


           WRITE:/(95) SY-ULINE.


           FORMAT COLOR COL_HEADING INTENSIFIED ON.


           WRITE:/1 SY-VLINE,2 'EXIT NAME',21 SY-VLINE ,22 'DESCRIPTION',95 SY-VLINE.


           WRITE:/(95) SY-ULINE.


           LOOP AT JTAB.

              SELECT SINGLE * FROM MODSAPT WHERE SPRSL = SY-LANGU AND NAME = JTAB-OBJ_NAME.

              

               FORMAT COLOR COL_NORMAL INTENSIFIED OFF.


                   WRITE:/1 SY-VLINE,2 JTAB-OBJ_NAME HOTSPOT ON,21 SY-VLINE ,22 MODSAPT-MODTEXT,95 SY-VLINE.


           ENDLOOP.


           WRITE:/(95) SY-ULINE.


           DESCRIBE TABLE JTAB.


           SKIP.


           FORMAT COLOR COL_TOTAL INTENSIFIED ON.


           WRITE:/ 'NO OF EXITS:' , SY-TFILL.


        ELSE.


           FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.


           WRITE:/(95) 'NO USER EXIT EXISTS'.


        ENDIF.

      ELSE.

          FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.


          WRITE:/(95) 'TRANSACTION CODE DOES NOT EXIST'.

      ENDIF.

 

AT LINE-SELECTION.

   GET CURSOR FIELD FIELD1.

   CHECK FIELD1(4) EQ 'JTAB'.

   SET PARAMETER ID 'MON' FIELD SY-LISEL+1(10).

   CALL TRANSACTION 'SMOD' AND SKIP FIRST   SCREEN.

 

*---END OF PROGRAM

 

 

 

OutPut Screen Shots

 

Userexit1.png

 

 

List of User Exits Screen Shot.

 

Userexit2.png

 


Generating Field catalog for ALV

$
0
0

There was requirement where in the report only a specific  fields  as per the work area defined in the program only was  required.

 

So first we generated the field catalog by

 

Passing ABAP Dictionary : Table Name

test.JPG

 

Using Program defined structure: only filtered the required fields in the report.

 

test.JPG

test.JPG

Add attachment to email step in Workflow through Program Exits

$
0
0

We get this requirement quite often to send attachments to email step in workflow. This can be achieved via programming exit. Same technique can be used for other relevant workflow steps.

 

Create a simple workflow with with email step.

 

workflow.png

Now create a class named ZCL_WF_ATTACH and add the interface IF_SWF_IFS_WORKITEM_EXIT to this class.

 

class1.png

Now lets implement method IF_SWF_IFS_WORKITEM_EXIT~EVENT_RAISED which comes with this interface.

 

METHOD if_swf_ifs_workitem_exit~event_raised .

   DATA: lv_id TYPE sww_wiid,

         lv_container TYPE REF TO if_swf_ifs_parameter_container,

         lv_attach TYPE TABLE OF obj_record,

         lv_folder_id TYPE soodk,

         lv_str TYPE string,

         lv_size TYPE so_obj_len,

         wa_document_info TYPE sofolenti1,

         lv_data TYPE sodocchgi1,

         lv_objtype TYPE swotobjid-objtype,

         lv_objkey TYPE swotobjid-objkey,

         lv_return TYPE swotreturn,

         lv_sofm TYPE swotrtime-object,

         lv_objject TYPE obj_record,

         tb_obj TYPE TABLE OF obj_record,

         it_solix_tab1 TYPE solix_tab.

   CHECK im_event_name = 'CREATED'.

* Fetch the workflow work item Id

   CALL METHOD im_workitem_context->get_workitem_id

     RECEIVING

       re_workitem = lv_id.

 

* Fetch Container

   CALL METHOD im_workitem_context->get_wi_container

     RECEIVING

       re_container = lv_container.

 

* Read attachment to confirm that there is no duplication

*CLEAR LV_OBJ_RECORD.

   TRY.

       CALL METHOD lv_container->get

         EXPORTING

           name  = '_ATTACH_OBJECTS'

         IMPORTING

           value = lv_attach.

     CATCH: cx_swf_cnt_elem_not_found,

   cx_swf_cnt_elem_type_conflict,

   cx_swf_cnt_unit_type_conflict,

   cx_swf_cnt_container.

   ENDTRY.

 

 

   IF lv_attach IS INITIAL.

     CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'

       EXPORTING

         owner     = sy-uname

         region    = 'B'

       IMPORTING

         folder_id = lv_folder_id.

 

* Create and set document

     DO 5 TIMES.

       CONCATENATE lv_str 'Hello' ',' 'my' ',' 'friend!' cl_abap_char_utilities=>cr_lf INTO lv_str.

     ENDDO.

*---you can use CL_DOCUMENT_BCS class for this purpose

     CALL METHOD me->string_to_solix

       EXPORTING

         iv_string   = lv_str

         iv_codepage = '4110'

       IMPORTING

         et_solix    = it_solix_tab1

         ev_size     = lv_size.

 

     lv_data-obj_name   = 'Test Sending Attachments'.

     lv_data-obj_descr  = 'Attachment 1'.

     lv_data-obj_langu  = sy-langu.

     lv_data-sensitivty = 'P'.

     lv_data-doc_size   = lv_size.

 

     CALL FUNCTION 'SO_DOCUMENT_INSERT_API1'

       EXPORTING

         folder_id                  = lv_folder_id

         document_data              = lv_data

         document_type              = 'XLS'

       IMPORTING

         document_info              = wa_document_info

       TABLES

         contents_hex               = it_solix_tab1

       EXCEPTIONS

         folder_not_exist           = 1

         document_type_not_exist    = 2

         operation_no_authorization = 3

         parameter_error            = 4

         x_error                    = 5

         enqueue_error              = 6

         OTHERS                     = 7.

* Populate object type and object key for create an instance

     lv_objtype = 'SOFM'.

     lv_objkey  = wa_document_info-doc_id.

 

     CALL FUNCTION 'SWO_CREATE'

       EXPORTING

         objtype           = lv_objtype

         objkey            = lv_objkey

       IMPORTING

         object            = lv_sofm

         return            = lv_return

       EXCEPTIONS

         no_remote_objects = 1

         OTHERS            = 2.

 

* Prepare for attaching the object to container

     lv_objject-header = 'OBJH'.

     lv_objject-type    = 'SWO'.

     lv_objject-handle  = lv_sofm.

     APPEND lv_objject TO tb_obj.

*---can be used for other workitems

     CALL METHOD lv_container->set

       EXPORTING

         name  = '_ATTACH_OBJECTS'

         value = tb_obj[].

*--this will add the attachment to email

     CALL METHOD lv_container->set

       EXPORTING

         name  = 'ATTACHMENTS'

         value = tb_obj[].

 

* Commit the changes

     CALL METHOD im_workitem_context->do_commit_work.

   ENDIF.

ENDMETHOD.

 

Here is the screenshot of other methods used. You can directly use CL_DOCUMENT_BCS for this conversion or other methods available to do the conversion.

 

class2.png

class3.png

class4a.png

Complete code for method STRING_TO_XSTRING

 

method STRING_TO_XSTRING .

   DATA lo_conv TYPE REF TO cl_abap_conv_out_ce.

     DATA lv_bom TYPE xstring.

     DATA lv_xbuf TYPE xstring.

     DATA lv_cp TYPE abap_encod.

 

     TRY.

 

         IF iv_convert_cp IS INITIAL.

 

           EXPORT p = iv_string TO DATA BUFFER lv_xbuf.

           IMPORT p = ev_xstring FROM DATA BUFFER lv_xbuf

                  IN CHAR-TO-HEX MODE.

 

         ELSE.

 

           IF iv_codepage IS INITIAL.

             lv_cp = cl_sx_mime_singlepart=>get_sx_node_codepage( ).

           ELSE.

             lv_cp = iv_codepage.

           ENDIF.

 

*       convert string to xstring using class cl_abap_conv_out_ce

*       in this form available also in 620

           lo_conv = cl_abap_conv_out_ce=>create(

             encoding = lv_cp

             ignore_cerr = 'X' ).

           lo_conv->write( data = iv_string ).

           ev_xstring = lo_conv->get_buffer( ).

 

*       add the byte order mark

           IF iv_add_bom = 'X'.

             CASE lv_cp.

               WHEN '4110'.                                  "UTF-8

                 lv_bom = cl_abap_char_utilities=>byte_order_mark_utf8.

               WHEN '4102'.                                  "UTF-16BE

                 lv_bom = cl_abap_char_utilities=>byte_order_mark_big.

               WHEN '4103'.                                  "UTF-16LE

                 lv_bom = cl_abap_char_utilities=>byte_order_mark_little.

             ENDCASE.

             IF lv_bom IS NOT INITIAL.

               CONCATENATE lv_bom ev_xstring INTO ev_xstring IN BYTE MODE.

             ENDIF.

           ENDIF.

         ENDIF.

 

       CATCH cx_root.                                        "#EC *

         RAISE EXCEPTION TYPE cx_bcs

           EXPORTING

             error_type = cx_bcs=>creation_failed.

 

     ENDTRY.

endmethod.

 

if you want to add IDOC or any standard document as attachment then use below code.

 

* Populate object type and object key for create an instance

     DATAlv_objtype TYPE swo_objtyp,

           lv_objkey   TYPE swo_typeid,

           lv_sofm     TYPE swotrtime-object,

           lv_return   TYPE swotreturn.

     lv_objtype = 'IDOCORDERS'.

     lv_objkey  = '0000000022238440'.

 

*Creating SOFM object

 

     CALL FUNCTION 'SWO_CREATE'

       EXPORTING

         objtype           = lv_objtype

         objkey            = lv_objkey

       IMPORTING

         object            = lv_sofm

         return            = lv_return

       EXCEPTIONS

         no_remote_objects = 1

         OTHERS            = 2.

 

* Prepare for attaching the object to container

     DATA: lv_object TYPE obj_record,

           tb_obj    TYPE TABLE OF obj_record.

 

     lv_object-header = 'OBJH'.

     lv_object-type    = 'BO'.

     lv_object-handle  = lv_sofm.

     APPEND lv_object TO tb_obj.

 

     CALL METHOD lv_container->set

       EXPORTING

         name  = '_ATTACH_OBJECTS'

         value = lv_object.


Now once we are done with class creation add this class in the program exits tab of email step.

 

attach.png

Now we are done activate the workflow and execute and check the email in SAP inbox.

 

email.jpg

 

 

You can use similar method to add PDF or other attachments.

Working with Zebra Printers using Smartforms in SAP

$
0
0

One of the requirements in my project was to print Labels on Zebra printers. The labels were designed using Smartforms. For which I faced some challenges and could not find detailed solution document online explaining the way of working with Zebra printers.

 

So I decide to document my experiences on the way of working with Zebra printers.

 

Sap has provided some notes for the list of device types that can be used by Zebra. PFB some of the SAP-Note numbers for reference.

 

1130927 - SAP Printer Vendor Program

 

1100779 - Participants in the SAP Printer Vendor program

 

750002 - Support for Zebra label printer (ZPL2)

 

750772 - Information about the ZPL-II printer driver for Smart Forms.

 

1696511 - Problems when printing in landscape format on Zebra printers.

 

1173046 - Printer Vendor Wizard Note: Zebra.

 

This document is based on the information from the above SAP-Notes. Please note that the conclusions in this document are purely based on my experience and the documentation I came across, so if there is any scope of improvement in this document, then please add your comments where ever needed. It is necessary to have the notes as reference before you proceed any further with the document.

 

Note:  You can either use transaction SNOTE in SAP or the SAP market place to view the contents of the  SAP Notes. Link for SAP Market Place is

          https://websmp202.sap-ag.de/notes

 

The Challenges I faced during the development are:

  1. Which device type to use
  2. Orientation issues
  3. Font Issues
  4. Barcode issues (Printing and Scanning)

 

Points 3 & 4 are generic to every printer or device type and same approach should be followed when facing such issues.

 

1)  Which device type to use:

    

     The selection of the device type is based on the following 2 factors

    

  • a)      DPI resolution of the printer, and
  • b)      Orientation of the label

    

SAP-Note ‘750772’ and ‘1173046’ will help you with the selection of device type based on the DPI resolution of the printer.

 

Now you will have 2 device types, one each from the above 2 Notes. For example let’s assume that the printer has 203 DPI resolution, so the device types that we now have after selection are LZEB2 and YZB200.

2) Orientation issues:

 

Now you have to decide the orientation of the label. This is again based on the width of the paper feed on the printer. Different printers from Zebra have different widths, ask for the relevant information and then decide based on the below explanation.

 

Note:  Most of the Zebra printers have Continuous media, so height of the label is not a concern, only thing to take into account is the width of the paper feed on the printer.

 

Before I proceed further I believe you have the basic understanding of the orientations, Portrait and Landscape orientations.

 

Portrait Orientation:

 

Let’s say the width of the printer paper is 110 MM,

And the specifications for label you are designing is 170 (h) * 110 (w) as below

Capture.PNG

In this case we use device type LZEB2 only.

 

Landscape Orientation:

For the same printer with a paper feed of width 110 MM,

And the Specification of the label design is 110 (h) * 170 (W) as below

Capture.PNG

Here the width of the label is bigger than the actual width of the paper feed on the printer, so this requires us to go for Landscape orientation and print the document as below by rotating the label 90 degrees.

Capture.PNG

 

But based on the note there is no command in ZPL-II for rotating the whole output. So to achieve this there are 2 options

 

I.                   Using Device type LZEB2

II.                  Using Device type YZB200

 

 

Using Device type LZEB2:  According to Note 750772 it is not possible to use Landscape orientation with the device types mentioned in this note because there no command in printer language ZPL-II to rotate the whole output of the label by 90 degrees. So always use portrait only.

The work around to achieve the landscape orientation is that there is a command ‘^FWR’ in the ZPL-II printer control language that rotates each individual field by 90 degrees(clockwise). If you insert this command into the output data stream using the mechanism of command nodes in Smartform for each individual field, then we can achieve the rotation ofindividual fields at printout. Similarly barcode rotation can be obtained by

specifying the rotation option while creating the barcode. But first you have to use portrait orientation only in the Smartform and then design the layout accordingly in the Smartform with a command node with the rotation command for each individual field.

Below Screenshot illustrates the implementation of the above idea in Smartform.

Capture.PNG

 

By doing the above you can achieve the rotation of the text written in the text node ‘FROM’ but only while it is being printed on the paper not in the preview. So it is necessary that you have the concerned printer available with you to test, because this is going to take a lot of effort arranging the fonts on the label. For more information please refer to section 2 in note 750772.

 

Using Device type YZB200: According to note 1696511 it is possible to print in landscape orientation on zebra printers using device type YZB200, but the problem is that the print is not rotated on the printer as below

 

Capture.PNG

 

Instead it is printed like this

Capture.PNG

 

So using device type YZB200 it does allow us to print in landscape orientation but to get the correct output the printer paper width should not be less than the width of the label. If the width of the printer is less than the label then the label above is truncated at the end as below

 

Capture.PNG

So the understanding from this is that it is possible to print the labels in landscape orientation on Zebra printer, but the width of the paper feed on the printer should be same as the width of the label design else there will be truncation at the end.

 

So final Conclusion on which device type to use for zebra printers is:

For portrait orientation use – LZEB2

For Landscape Orientation use – YZB200 (But make sure width of the paper feed is not less than the label width)

 

3)Font Issues:

 

If you don’t use the correct font in your Smartform then you will have issues printing the label on the printer or while you are seeing a preview using the respective printer (it will work fine with the LOCL/LP01 printer).

 

In such cases it will give the below error message.

‘Table ‘XYZ’ does not fit into Window’

And this is mainly because, the table (template) ‘XYZ’ in some window cannot accommodate the data and the data inside this window is exceeding the size of the window or the whole page. As written above there will be no issues if you are using LOCL / LP01 device for preview, now the question here is why issues with the other devices ?  Let’s not come to a direct conclusion on this, and let’s figure this out by trials.

 

Now if you try and reduce the size of the template in the window (in Smartform) by half of it then you can see the preview but you will see bigger size letters and may be a different font. That is because the printer does not support the font you have used in the Smartform and by default SAP takes the default font of the printer and uses that in the Smartform and hence you see a bigger font size and possibly a different font style.

 

So it is advisable to use fonts that are available for the device type associated with the printer.

 

You can check the printer fonts by using transaction SE73.

Steps to check the printer fonts:

Go to SE73.

Capture.PNG

Select printer fonts radio button and click display. It will take you to the next screen where all the SAP defined device types and custom device types (newly created or loaded) in SAP are listed.

 

Capture.PNG

 

Select your device type and double click to see the list of fonts available for that device type.

 

Capture.PNG

So in this case only Helve is maintained, so it is better to use Helve only in your Smartform, One more thing to know here is no matter what you have in Smartform the print will always haveBOLD text only because of the bold settings in the printer font( see screenshot above).

 

It can have different font Sizes though, I did not have to maintain different sizes in the printer fonts but the labels were printed with their corresponding size.

 

If your requirement is to have a specific font then you can add that Font to the printer device type and this will be a Basis activity.

 

4) Barcode issues (Printing and Scanning):

 

First thing to know about barcodes is that the preview and the actual print from the printer are not the same. So try to adjust your layout based on the printout form the printer and not based on the preview.

 

Let me show you what I actually meant by this.

 

Preview in SAP:

Capture.PNG

 

Actual printout from the printer:

 

Capture.PNG

Both the screenshots above were created using the same barcode CD39__00 barcode, and symbology Code39 but the barcodes in the preview and the actual print are totally different and that is the reason why it is advised to design the layout based on the actual printout from the printer.

 

The second thing to know about barcodes in SAP is that there are only a few barcode symbologies that are supported by SAP and are available in system by default.

The barcode symbologies supported by SAP are:

Capture.PNG

These are the basic barcodes types using which we can create a barcode. And SAP has provided few barcodes using these and these are also available in SAP by default.

 

Both printer barcodes and System barcodes can be checked in transaction SE73 (see below).

 

Capture.PNG

Display system barcodes to see the list of barcodes supported by SAP (see below).

 

Capture.PNG

 

The screenshot above shows few of the default barcodes supported by SAP. The barcode highlighted in the above screen was created using the new barcode technology and the others are created using conventional technology. You can also create your own barcodes here. More information regarding how to create barcodes in SAP can be found online.

 

The next step with barcodes is to check which barcodes are supported by the printer. Let’s assume that your requirement is to use a barcode of symbology Code_39 so first check if the printer has any default barcodes with this symbology.

 

To check printer barcodes, go to SE73 and display printer barcodes and go to printer LZEB2 and double click to list all barcodes supported by printer device type.

 

Capture.PNG

Basically these are standard barcodes that are also supported by SAP. The highlighted ones in the screenshot above use Code_39 symbology. Try using one of these in your layout and see if it meets your requirements and make sure you design the layout based on the actual print form the printer not based on the preview of the Smartform.

 

Using the barcodes supported by the printer will ensure that they are easily scanable and read by the scanner. If you use any other system barcode which is not supported by the printer then also you will get the barcode printed on the label but we will have issues scanning the barcode. So it is better to stick to using the barcodes provided by the printer.

 

If listed barcodes does not meet your requirement (may be because you need a barcode with less width or height to accommodate on your label) then you have to create a new system barcode and assign it to the printer device.

 

This part is dealt in more detail in the other document with name ‘How to print Custom barcodes’ that i am planning to publish soon.

 

Apart from this you can also have alignment issues with the barcodes. To align a barcode you can do the following.

 

  • Go to Smartstyle you have used in the program, select the respective node you haveassigned for the barcode. Here try changing the alignment and spacing values and try giving it a few trials. You will be able to align barcodes after a few combinations.

        Capture.PNG

  • Sometimes if there is not enough space in the column of a template or the table cell thenthe barcode placed inside them will skip one line and print the barcode in second line. To align the barcode properly with the other barcodes in the adjacent columns you can either increase the size of that column to accommodate the barcode or if that is not possible then reduce the sizes of the other adjacent columns so that the other columns also skip a line. An example for this issue is as below.

        Capture.PNG

In the above screenshot there is an alignment issue with the barcodes but there is no space on the page to increase the size of the 2nd column, to align them we have to reduce the size of the 3rd and 4th columns by adding an empty column, either one empty column each after the 3rd and 4th columns or reduce the size of 3rd and 4th columns a little bit (very nominal) and add an extra column just before the third as shown in the below screen shot.

 

Capture.PNG

 

This will make the barcode shift to the next line in 3rd and 4th columns also. So this will align the barcodes properly as shown in the below screenshot.

 

Capture.PNG

 

                                                                                                                             ----- ' THE END ' ------

 

AS i have already written earlier, So please note that the conclusions in this document are purely based on my experience and the documentation I came across online, so if there is any scope of improvement in this document, then please add your comments where ever needed.

Create an SAP DMS document attaching a file from the Application Server and checking in an FTP vault with automatic filename creation

$
0
0

Hi all,

 

So, as you can see from the title, I had a very specific requirement. I needed to be able to create a document (those you can open through CV03N) programmatically attaching a file from the application server and with an FTP server that automatically assigns filenames.

 

I searched google/scn extensively for a way to do this or an example and tried a few, but it seems that the configuration options for DMS are so vast that it was unlikely to find an example that suited my needs and my configuration. So I'm sharing my code and my example, hoping that maybe it will be helpful for someone else, and maybe I'll even need it myself in the future.

 

The code ended up being extremely simple, but I assure you I tried so many really complex approaches that I don't even want to remind myself of them again

 

  1. DATA:
  2.       lv_docty  TYPE dokar,
  3.       lv_docnr  TYPE doknr,
  4.       lv_docpr  TYPE doktl_d,
  5.       lv_docvr  TYPE dokvr,
  6.       ls_ret    TYPE bapiret2,
  7.       lt_files  TYPETABLE OF bapi_doc_files2,
  8.       ls_files  LIKELINE OF lt_files,
  9.       ls_documentdata TYPE bapi_doc_draw2.
  10. CLEAR ls_documentdata.
  11. ls_documentdata-documenttype ='ZCL'.
  12. ls_documentdata-description ='Testing DMS'.
  13. ls_documentdata-username = sy-uname.
  14. CLEAR ls_files.
  15. ls_files-originaltype ='1'.
  16. ls_files-storagecategory ='<VAULT NAME HERE>'.
  17. ls_files-docpath ='/tmp/'.
  18. ls_files-docfile ='dms_test4.pdf'.
  19. ls_files-wsapplication ='PDF'.
  20. APPEND ls_files TO lt_files.
  21. CALL FUNCTION'BAPI_DOCUMENT_CREATE2'
  22.   EXPORTING
  23.     documentdata    = ls_documentdata
  24.     pf_ftp_dest     ='SAPFTPA'
  25.     pf_http_dest    ='SAPHTTPA'
  26.   IMPORTING
  27.     documenttype    = lv_docty
  28.     documentnumber  = lv_docnr
  29.     documentpart    = lv_docpr
  30.     documentversion = lv_docvr
  31.     return          = ls_ret
  32.   TABLES
  33.     documentfiles   = lt_files.
  34. IF ls_ret-typeNE'E'.
  35.   CALL FUNCTION'BAPI_TRANSACTION_COMMIT'
  36.     EXPORTING
  37.       wait = abap_true.
  38. ELSE.
  39.   CALL FUNCTION'BAPI_TRANSACTION_ROLLBACK'.
  40. ENDIF.

 

 

And the result:

 

Display Document_ Basic Data Customer Claim (ZCL).png

 

I hope this will be helpful to someone!

 

Best regards,

Bruno

Viewing all 935 articles
Browse latest View live


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