Quantcast
Channel: SCN : All Content - ABAP Platform Developer Center
Viewing all 29 articles
Browse latest View live

Addition of watermark in an Adobeform

$
0
0

Objective:

 

  The Main objective of this paper is to

 

  • Brief the importance of watermarking documents.
  • Brief the procedure of adding watermark in adobe forms and make it still more customizable,

Which help the Developers/Clients to make their work easier, effective, and reusable.

 

Introduction to Adobe Forms:

 

SAP Adobe Forms is a result of cooperation between SAP and Adobe – represent state-of-the-art print technology in the SAP system. Thanks to the successful cooperation, SAP users can use forms in a commonly known and accepted PDF format. The usage of the PDF format means that forms retain their appearance regardless of the environment they are used in.

We are going to focus on SAP Adobe forms with Watermark using ABAP workbench and Adobe Life cycle Designer.

 

What are Watermarks and their usability:

 

Watermark is a recognizable image or pattern in paper that appears as various shades of lightness/darkness.

 

Watermarks can be a valuable asset to any document. They help convey the status of a document such as the "Draft" or the importance of the data in the case of a "Confidential" watermark. They also help the differentiating between copy and original documents with "Copy" and "Original" water mark respectively.

Watermark ensures that the copyright owner's name / company logo is superimposed on the documents.

 

 

Procedure to add watermarks on Adobe forms:

 

For adding watermarks in the adobeform we have to make the change in the layout level. We have to go to transaction sfp for this.

Enter the form name in the box and open it in change mode.


Select the layout tab .


Select the master tab and insert an image from the library


This will make a new field in the hierarchy of the master page. And also a box will come up on the layout .Right click on the box and select “Choose image” from the menu.


 

Select the image and click open, this will add the image and will be displayed on the form. Once the image is added ,right click on it again and select “Send Backward”. This will make it behave as a watermark. The image will be in background and any text on body page will be front of the image.

 

Example of the Adobe form with Watermark.




Extension of PROACT IDoc

$
0
0

Objective:

 

  The Main objective of this paper is to

  • Brief about PROACT IDoc.
  • Brief the procedure of extending/customizing PROACT IDoc to inform vendors about the stock situation and forecast and to trigger it from Custom code.

 

Introduction to PROACT IDoc

 

PROACT IDoc is used to transfer demand and stock data to SAP Supply Network Collaboration (SAP SNC) and SAP Inventory Collaboration Hub (SAP ICH) so that a supplier can see it and plan deliveries accordingly. The standard report to trigger IDoc are RSMIPROACT and RSMIPROACT02. Its reads/packs stock and demand data in  ERP system to be send to the SAP SNC/ICH system.

 

The business scenarios PROACT IDoc can be used are:

 

●  Supplier Managed Inventory (SMI)

●  Release Processing (RP)

●  Dynamic Replenishment (DR)

 

The IDoc generated are on the basis of vendors so if 50 materials with seven vendors as sources, it creates seven PROACT01 IDocs containing the demand and stock data for the number of materials of each vendor. The system takes account of which vendor is the source for which material when it creates the IDocs.

 

Now we are going to focus on extending/customizing the IDoc to send additional/Custom information.

 

Procedure to extend PROACT IDoc

 

The method we will use to extend the PROACT IDoc is implementing a Business Add-In (BADI) in the standard Function Module which is used to create the IDoc.

 

The process will be as follows:

 

  1. Create the Custom Segment with the field you want to add in WE31 and release the segment by using “SET RELEASE”. 
  2. Create an Extended IDoc type and Link it to Standard Basic IDoc type “PROACT01” using WE30.
  3. Add the custom segment to the Extended IDoc type and release the same by using “SET RELEASE”.
  4. Create a second entry for message type “PROACT” in WE82 with basic IDoc type as “PROACT01” and Extended IDoc type name.
  5. Implement the BADI “SMI_IDOC_PROACT_OUT”/method “CHANGE_BEFORE_SEND” to fill the custom segment.The BADI has been provided as an exit to Function Module “SMI_MASTERIDOC_CREATE_PROACT”.
  6. Data for the custom segment can be fetched inside the BADI. The only passing parameter to BADI are the IDoc item and header data table ,so data in the standard segments can be used fetch custom data.

For example

a) e1adrm1-partner_id contains Plant info when e1adrm1-partner_q = _WE.

b) e1adrm1-partner_id contains Vendor info when e1adrm1-  partner_q = _LF.

                        c) e1edp19-idtnr contains MATNR.

 

But if you want to trigger the IDoc from a custom program the additional method which needs to be followed are as follows:

 

Copy the Perform “idoc_create_proact” from the standard program RSMIPROACT2 (Include SMIPRF01) .The perform sorts and sends the IDoc based on vendor. The perform has many checkbox variables which are not mandatory and can be passed based on the requirement.

The passing parameter for the perform are Vendor list, Material source data and Plant ,its collects data and breaks them down into several Internal tables (which are the passing parameter for the FM 'SMI_MASTERIDOC_CREATE_PROACT')

The maximum number of material number which can be send for a vendor is capped at 200.

 

CALL FUNCTION 'SMI_MASTERIDOC_CREATE_PROACT'

 

EXPORTING

pi_supplier                = l_supplier             " Vendor

pi_logsys                  = fp_g_logsys         " Logical system

pi_plant                     = fp_g_werk           " Plant

pi_mat_source           = li_mat_source      " Product Source table

pi_articles                  = li_product_cap    " Capped Materials List table

pi_labst_items           = li_labst          " Unrestricted-use stock (Total Area) table

pi_klabst_items         = li_klabst        " Unrestricted-use stock (consignment)table

pi_slabst_items         = li_slabst         " Unrestricted-use stock (equity) table

pi_insme_items         = li_insme         " Quality inspection (Total Area)table

pi_kinsme_items       = li_kinsme       " Inspection stock (consignment)table

pi_sinsme_items       = li_sinsme        " Inspection stock (equity) table

pi_speme_items        = li_speme         " Blocked Stock (Total Area) table

pi_kspeme_items      = li_kspeme       " Blocked Stock (consignment) table

pi_sspeme_items       = li_sspeme       " Blocked Stock (equity) table

pi_umlme_items       = li_umlme        " Stock in Transfer table

pi_demand_items     = li_demand       " Demand data (SMI) table

pi_docnum                = l_idoc_temfp_id   " Doc Number

pi_koneig_flag          = c_true            " Flag

pi_labst_flag             = c_true            " Flag

pi_insme_flag           = c_true            " Flag

pi_speme_flag           = c_true            " Flag

pi_umlme_flag = l_stockintransfer " Flag

iv_dependent_ind     = l_ms              " Flag (SPACE)

            

IMPORTING

pe_idoc_header_item = lw_idoc_header_item   "IDoc Header Data

 

TABLES

pe_idoc_data_items  = li_idoc_data_items.         "IDoc item Data

Change field labels of Standard Transactions of SAP

$
0
0

Objective:

 

  The Main objective of this paper is to

 

  • Brief the procedure of changing field labels of Standard Transactions of SAP.

For example on screen of shipping Information (Transation:VT02N) we have many fields for additional data which we can use to store specific information (Like Vehicle details or driver details).Here our objective will be to change the field label to help the end users recognize and enter only specific information.

We will change the following field labels.

 

The field Addit text 1 should be renamed to Driver ID.

The field Addit text 2 should be renamed to Driver name.

The field Addit text 3 should be renamed to License plate.

 


Procedure to change the field labels:

 

 

The method we will use to change the field label can be used on any standard transaction fields.

 

The process will be as follows:

 

1) First get the data element of the field of which field label is to be changed. For that use F1 on the field and go to technical details.

 

 

2) To change the field labels use transaction CMOD->Go to->Text Enhancements-> Keyword->Change.

 

3) Enter the Data Element of the field you want to change the text of.

4) Change the field label of the data element.

 

5)Execute the transaction the field label should be changed by now.

ABAP program for uploading stock adjustment.

$
0
0

Process scenario : In retail IT environment there are numerous systems integrated which has seamless communication to the SAP system. Since there are dependency of data which flows from third party systems continuously into SAP, this  needs to be validated to control the type of data making it completely error free while it is received or posted to SAP system.

 

Problem :

 

Goods Movement IDOC comes from host (NON SAP) which fails due to gap in reason code mapping between  host and SAP system.


  1. Correction :

 

The only way out to correct this problem is by identifying the data from the idocs which were failed and post them into SAP via MIGO transaction code manually..

 

   2. Bottleneck :

 

The frequency of failure occurrence depends upon the data flown to SAP as idocs from third party systems. If the data is so huge the rectification via manual posting becomes tedious to get these failure documents corrected and  posted through MIGO transaction. In a  normal scenario this would require three hours / day for performing this activity.


   3. Feasible solution :

 

A mechanism to be developed to post erratic data via a custom program in SAP for bulk uploading that could handle document creations in a single stretch. And thereby reducing human effort spent to achieve correction which is currently being done manually posting them one by one.

 

This requirement could be achieved by using the  BAPI_GOODSMVT_CREATE a standard BAPI provided by SAP in a custom developed program that could cater the necessity of uploading of data. The program shown below gets the file path, row begin and row end as inputs . Here in the figure 1.1 the local file path is set along with the row begin and column begin inputs. Generally in the source file the first row would be header so row begin would be 2 and end row we could consider as 5 and varies depends on the data that is to be processed.

 

 

Fig 1.1

 

fig1.1.png

After executing the program we get the log as shown in Fig 1.2 about the successful or unsuccessful updating.

 

Fig 1.2

fig1.2.png

 

Now lets see the core coding part of the program developed. This program has minimal procedural approach at the front end but has a class lying underneath which handles the major operations of the program such as loading the source file, preliminary checks, converting the source file to the desired format to make it ready for the uploading and finally posting the documents and getting the result for display through ALV output. We will see below step by step process involved in developing the component.

 

Step1. Create a structure ZST_GOODSMVT_UPL as shown in figure 1.3.

 

Fig 1.3.

 

fig1.3.png

Create the table types :

 

ZTT_GOODSMVT_ITEM for line type BAPI2017_GM_ITEM_CREATE

ZTT_BAPIRET2 for line type BAPIRET2,

ZTT_GOODSMVT_UPL for line type ZST_GOODSMVT_UPL.

 

 

Step 2. Create a class ZCL_GOODSMVT_UPLOAD with three methods as shown below.We will see each method and its parameters in detail.

 

Figure 1.4

fig1.4.png

 

Parameters for method MAP_FILE_PATH

 

Figure 1.5

fig1.5.png

Add the below code into this method. :

 

method map_file_path.

field-symbols : <ls_file> type file_table.

call method cl_gui_frontend_services=>file_open_dialog
exporting
window_title            = 'Choose File to be Uploaded'
default_extension       = '.xls'
changing
file_table              = e_filetab
rc                      = lv_rc
exceptions
file_open_dialog_failed = 1
cntl_error              = 2
error_no_gui            = 3
not_supported_by_gui    = 4
others                  = 5.

if sy-subrc <> 0.
  message e001(zgmupl).
else.
  read table e_filetab assigning <ls_file>  index 1.
  if sy-subrc eq 0.
   e_filename = <ls_file>-filename.
  endif.
endif.

  endmethod.


Parameters for method UPLOAD_FILE.

 

Figure 1.6

fig1.6.png


After creating the parameters the below code is added to the method.

 

method upload_file.

data : lt_file  type table of kcde_cells,
ls_final type zst_goodsmvt_upl,
lr_ex    type ref to cx_root,
lv_msg   type string.


field-symbols : <ls_file> type kcde_cells.

clear gt_final.
call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
exporting
filename                = i_filename
i_begin_col             = i_begcol
i_begin_row             = i_begrow
i_end_col               = i_endcol
i_end_row               = i_endrow
tables
intern                  = lt_file
exceptions
inconsistent_parameters = 1
upload_ole              = 2
others                  = 3.
if sy-subrc <> 0.
  message e002(zgmupl).
else.
  sort lt_file by row col.

endif.

clear : e_keyid , e_fldval .
loop at lt_file assigning <ls_file> .

try .
case <ls_file>-col.

when 1.
ls_final-keyid = <ls_file>-value.

when 2.
ls_final-budat = <ls_file>-value.

when 3.

ls_final-bldat = <ls_file>-value.

when 4.
ls_final-bktxt = <ls_file>-value.

when 5.
ls_final-matnr = <ls_file>-value.

when 6.
ls_final-plant = <ls_file>-value.

when 7.
ls_final-lgort = <ls_file>-value.

when 8.
ls_final-bwart = <ls_file>-value.

  when 9.
ls_final-erfmg = <ls_file>-value.

when 10.
ls_final-erfme = <ls_file>-value.

when 11.
ls_final-sgtxt = <ls_file>-value.

when others.
endcase.

catch cx_root into lr_ex.

e_keyid = ls_final-keyid.
e_fldval = <ls_file>-value.
e_exmsg = lr_ex->get_text( ).

return.

endtry.

if <ls_file>-col = i_endcol.
append ls_final to gt_final.
clear ls_final.
continue.
endif.
endloop.

endmethod.


Parameters for method POST_GOODSMVT_UPLOAD.


fig1.7.png


Create the below code into the above method.

 

method post_goods_mvt.

call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header               = i_header
goodsmvt_code                 = i_code
TESTRUN                       = ' '
IMPORTING
GOODSMVT_HEADRET              e_headret
MATERIALDOCUMENT              e_matdoc
MATDOCUMENTYEAR               e_docyr
  tables
goodsmvt_item                 = i_item
return                        = e_return
.

if sy-subrc eq 0.

endif.

endmethod.

 

Now that we have created the parameters and methods, we have to create a main program to instantiate and use this class for our purpose.

 

Create a program ZMM_GOODSMVT_UPLOAD .

 

Create a top include ZMM_GOODSMVT_UPLOAD_TOP which has the global declarations.

 

TYPES : BEGIN OF ty_final.
INCLUDE STRUCTURE zst_goodsmvt_upl.
TYPES : END OF ty_final.


TYPES: BEGIN OF ty_log ,
keyid TYPE char10,
message TYPE bapi_msg,
END OF ty_log.


DATA : go_goodsmvt  TYPE REF TO zcl_goodsmvt_upload,
gt_filetab TYPE filetable,
gt_final TYPE TABLE OF ty_final,
gs_final TYPE ty_final,
  gt_log TYPE TABLE OF ty_log,
gs_log TYPE ty_log.

DATA : gv_file TYPE rlgrap-filename. " file name

DATA :    gs_header  TYPE bapi2017_gm_head_01,
gv_code    TYPE char2,
gt_item    TYPE TABLE OF bapi2017_gm_item_create,
gs_item    TYPE bapi2017_gm_item_create,
gs_headret TYPE bapi2017_gm_head_ret,
gv_matdoc  TYPE bapi2017_gm_head_ret-mat_doc,
gv_docyr   TYPE bapi2017_gm_head_ret-doc_year,
gt_return  TYPE TABLE OF bapiret2.

CONSTANTS : gc_code TYPE char2 VALUE '03'.

FIELD-SYMBOLS : <gs_return> TYPE bapiret2,
<gs_final> TYPE zst_goodsmvt_upl.


PARAMETERS : sp_file   TYPE rlgrap-filename,
sp_brow   TYPE i,
sp_bcol   TYPE i DEFAULT '1' NO-DISPLAY,
sp_erow   TYPE i,
sp_ecol   TYPE i DEFAULT '11' NO-DISPLAY.

 

 

Create another include ZMM_GOODSMVT_UPLOAD_F01.  which handles the required routines.

 

First we will have a look at the main program

and the subsequent performs we see in it are created in the include ZMM_GOODSMVT_UPLOAD_F01.

 

REPORT  zmm_goodsmvt_upload.

INCLUDE zmm_goodsmvt_upload_top.
INCLUDE zmm_goodsmvt_upload_f01.

INITIALIZATION.

AT SELECTION-SCREEN.
*--validate the max row count
PERFORM validate_rows.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR sp_file.

CLEAR : gt_filetab,
gt_final.

CREATE OBJECT go_goodsmvt.

*--Map the file path
CALL METHOD go_goodsmvt->map_file_path
IMPORTING
e_filetab  = gt_filetab
e_filename = sp_file.

START-OF-SELECTION.
*--Upload the data from source file
PERFORM upload_data.
*--Display the output log
PERFORM display_output.

 

We will closely view each performs and the process they are assigned to carry out in the below .


Fig 1.8

fig1.8.png


For  PERFORM upload_datacreate the below code.

 

FORM upload_data .

DATA : lv_msg   TYPE char100,
lv_keyid TYPE char10,
lv_fldval TYPE char25,
lv_exmsg TYPE string.

CLEAR : gv_file, lv_keyid, lv_fldval, lv_exmsg.
gv_file = sp_file.

CREATE OBJECT go_goodsmvt.
*--Get the table values
CALL METHOD go_goodsmvt->upload_file
EXPORTING
i_filename = gv_file
i_begrow   = sp_brow
i_begcol   = sp_bcol
i_endrow   = sp_erow
i_endcol   = sp_ecol
IMPORTING
e_keyid    = lv_keyid
e_fldval   = lv_fldval
e_exmsg    = lv_exmsg
gt_final   = gt_final.
*--check for error
IF NOT lv_keyid IS INITIAL.

CLEAR lv_msg.
CONCATENATE text-011 lv_keyid text-012 lv_fldval lv_exmsg INTO
lv_msg SEPARATED BY space.
MESSAGE lv_msg TYPE 'S' DISPLAY LIKE 'E'.
RETURN.

ELSEIF  gt_final IS INITIAL.
*-- if no data found to be uploaded
MESSAGE text-009 TYPE 'S' DISPLAY LIKE 'E'.
RETURN.

ENDIF.

*--prepare for posting.
LOOP AT gt_final ASSIGNING <gs_final>.

CLEAR : gs_header, gs_headret, gv_matdoc,
gv_docyr, gt_return, gs_item.
*--Populate header
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external            = <gs_final>-budat
IMPORTING
date_internal            = gs_header-pstng_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external            = <gs_final>-bldat
IMPORTING
date_internal            = gs_header-doc_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS                   = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

gs_header-header_txt = <gs_final>-bktxt.

*--Populate item
UNPACK <gs_final>-matnr TO gs_item-material.

gs_item-plant     = <gs_final>-plant.
gs_item-stge_loc  = <gs_final>-lgort.
gs_item-move_type = <gs_final>-bwart.
gs_item-entry_qnt = <gs_final>-erfmg.
gs_item-entry_uom = <gs_final>-erfme.
gs_item-item_text = <gs_final>-sgtxt.

APPEND gs_item TO gt_item.
CLEAR gs_item.

AT END OF keyid.
*--call the BAPI to post the document
CALL METHOD go_goodsmvt->post_goods_mvt
EXPORTING
i_header  = gs_header
i_code    = gc_code
i_item    = gt_item
i_testrun = space
IMPORTING
e_headret = gs_headret
e_matdoc  = gv_matdoc
e_docyr   = gv_docyr
e_return  = gt_return.
*--of error in posting
IF NOT gt_return IS INITIAL.

LOOP AT gt_return ASSIGNING <gs_return>.
*--Prepare log
gs_log-keyid = <gs_final>-keyid.
CONCATENATE <gs_return>-type <gs_return>-id
<gs_return>-number <gs_return>-message
INTO gs_log-message SEPARATED BY space.
APPEND gs_log TO gt_log.
CLEAR gs_log.

ENDLOOP.

ELSE.
*--for successful posting
IF NOT gs_headret-mat_doc IS INITIAL.

*--commit work and wait. " for successful posting.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*--Prepare log
gs_log-keyid = <gs_final>-keyid.
CONCATENATE text-003 gs_headret-mat_doc text-002
gs_headret-doc_year text-004 INTO gs_log-message
SEPARATED BY space.

APPEND gs_log TO gt_log.
CLEAR gs_log.
ENDIF.
ENDIF.
CLEAR : gs_header , gt_item, gs_headret,
gv_matdoc, gv_docyr, gt_return.

ENDAT.
ENDLOOP.
ENDFORM. " UPLOAD_DATA

 

For PERFORM display_output use the below code.

 

FORM display_output .
*
DATA: lo_alv        TYPE REF TO cl_salv_table,
lx_msg        TYPE REF TO cx_salv_msg,     
lo_layout     TYPE REF TO cl_salv_layout,
lv_functions  TYPE REF TO cl_salv_functions_list,
lv_column     TYPE REF TO cl_salv_column_list,
lv_columns    TYPE REF TO cl_salv_columns,
lo_aggrs      TYPE REF TO cl_salv_aggregations,    
lo_key_col    TYPE REF TO cl_salv_columns_table .
*
DATA: ls_key        TYPE salv_s_layout_key,
lf_variant    TYPE slis_vari.
*
CONSTANTS : lc_x    TYPE c VALUE 'X'.
*
IF NOT gt_log IS INITIAL.
*--Calling the factory method
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table      = gt_log ).
CATCH cx_salv_msg INTO lx_msg.
EXIT.
ENDTRY.
lo_layout = lo_alv->get_layout( ).
*--set Layout save restriction
ls_key-report = sy-repid.
lo_layout->set_key( ls_key ).
lo_layout->set_save_restriction(           if_salv_c_layout=>restrict_none ).
*--set initial Layout
lf_variant = 'DEFAULT'.
lo_layout->set_initial_layout( lf_variant ).
*--activate ALV generic Functions
lv_functions = lo_alv->get_functions( ).
lv_functions->set_all( lc_x ).
lv_columns = lo_alv->get_columns( ).
lv_columns->set_optimize( lc_x ).
lo_aggrs = lo_alv->get_aggregations( ).
lo_key_col = lo_alv->get_columns( ).
lo_key_col->set_optimize( lc_x ).
lo_key_col->set_key_fixation( 'X' ).
*--visible columns
TRY.

lv_column ?= lv_columns->get_column( text-005 ).
lv_column->set_short_text( text-006 ).
lv_column->set_medium_text( text-006 ).
lv_column->set_long_text( text-006 ).

lv_column ?= lv_columns->get_column( text-007 ).
lv_column->set_short_text( text-008 ).
lv_column->set_medium_text( text-008 ).
lv_column->set_long_text( text-008 ).

CATCH cx_salv_not_found.
EXIT.
ENDTRY.
lo_alv->display( ).
ENDIF.
*
ENDFORM. " DISPLAY_LOG

 

These text elements are created

Fig 1.9

fig1.9.png

 

Selection texts created.

Figure 2.0


fig2.0.png

Source File format :


Key ID,

posting date

doc date,

header text,

Material,

plant,

storage,

Mov type,

entry qty,

UOM,

Item text

 

Maintain the source file as mentioned in the above format in the excel file. The first column Key ID serves as an identifier to combine the line items into a single document.

 

Scalability :

 

Though this class has been created specifically to cater the goods adjustment upload, this could  be further enhanced by adding appropriate new fields to the structure , adding new methods to take it into a complete object oriented pattern design and can be used for  uploading data related to goods movement.



 

 

 




 

 

 

 

 

 

 

 

 

 

 

 

 

.

HR: merge personnel numbers by report

$
0
0

Hi,

 

I used function module HRMGE_MERGE_CP_RELATIONSHIP from program RPMGE_CP_RELATION_MANIPULATION (behind the transaction HRMGE0090)

in an own report.

The function module has only 2 input parameters:

global id ( = CP object both personnel numbers will be assigned to)

pernr_tab containing 2 personnel numbers.

 

Now we are facing a problem:

If  we run the program for british employees with logon language DE the P0001-ENAME is changed from "Mr" to "Herr" ...

 

The transaction HRMGE0090 itself does not change P0001-ENAME.

Why?

How to prevent this?

 

Thanks in advance

Dynamic value passing for Flag Structure BAPI_ITOB(X)

$
0
0

Hi SCN,

 

I had to make a program for a costumer to import a CSV file into the system. The file itself contained information
on equipments to either change or create them. I did not copy the whole program (not being the purpose of this document).
The piece I wanted to share was to dynamicly fill the flag structures. If done by hand, this process could take quite
a while.

 

the data elements needed may depend on your needs.


data:    lv_equinr            TYPEequnr, "equipment number
           lv_input              LIKE LINE OFlt_input, "depending on needs (too long to dislpay the structure).
           lv_bapi_itob        TYPE bapi_itob, "data general
           lv_bapi_itob_x    TYPE bapi_itobx,"data generalx -> changed data

           lv_bapi_only       TYPE bapi_itob_eq_only, "data specific
          
l
v_bapi_only_x   TYPEbapi_itob_eq_onlyx."data specifix -> changed data
    
CONSTANTSlc_exclamation  TYPEVALUE '!'.
    
     "retrieve the data inside the csv file and put them in lv_input.
     PERFORMupload_file.
    
     "fill itob
     TRY.
         MOVE-CORRESPONDINGlv_input TOlv_bapi_itob.
         MOVE-CORRESPONDINGlv_input TOlv_bapi_only.
      CATCHcx_sy_conversion_no_number INTOerror_ref.
       err_text = error_ref->get_text( ).
       WRITEerr_text.
     ENDTRY.

     "lv_bapi_itob_x AND lv_bapi_only_x are not needed in case of a new equipment
     IF
lv_bapi_itobIS NOT INITIAL.

           "append X to lv_bapi_itob_x when lv_bapi_itob has value.
           DO.
              ASSIGN COMPONENT sy-index OF STRUCTURElv_bapi_itob TO<fs_bapi>.
              IFsy-subrc <> 0. EXIT. ENDIF.
             ASSIGN COMPONENTsy-index OF STRUCTURElv_bapi_itob_x TO<fs_bapix>.
             IF<fs_bapi>IS NOT INITIAL.
             "--Start-- Not needed, custom to specifications
                 IF<fs_bapi> EQlc_exclamation. "if value is '!', the value will be deleted and flagged as x in <fs_bapix>
                   <fs_bapi> = ''.
                 ENDIF.
             "--Stop--
                 <fs_bapix> = 'X'.
              ENDIF.
           ENDDO.

           "append X to lv_bapi_only_x when lv_bapi_only has value.
           DO.
              ASSIGN COMPONENT sy-index OF STRUCTURElv_bapi_only TO<fs_bapi>.
              IFsy-subrc <> 0. EXIT. ENDIF.
             ASSIGN COMPONENTsy-index OF STRUCTURElv_bapi_only_x TO<fs_bapix>.
             IF<fs_bapi>IS NOT INITIAL.
             "--Start-- Not needed, custom to specifications
                 IF<fs_bapi> EQlc_exclamation. "if value is '!', the value will be deleted and flagged as x in <fs_bapix>
                   <fs_bapi> = ''.
                 ENDIF.
             "--Stop--
                 <fs_bapix> = 'X'.
              ENDIF.
           ENDDO.


     ENDIF.
    
     CALL FUNCTION'BAPI_EQUI_CHANGE'
         EXPORTING
           equipment                = ls_equinr       "gets value from lv_input in PERFORM upload_file
           data_general            = lv_bapi_itob   
           data_generalx          = lv_bapi_itob_x
           data_specific           = lv_bapi_only
           data_specificx          = lv_bapi_only_x
      IMPORTING
          return                   = ls_message
                 .
       IFsy-subrc EQ0.
         CALL FUNCTION'BAPI_TRANSACTION_COMMIT'.
       ENDIF.

Smartform : Accessing Multiple Page Layouts From A Single Form

$
0
0
Hey There,
I am explaining the concept of calling multiple forms having each different layout from single form.
By creating the different pages (having different layout) in the single form and based on the condition type we can trigger the specific page.
Below is the Step to Step process which shows you how to create the form like that.

Step 1: Creation of Smart form With Multiple Page:
                                        Here I am taking example of 5 forms (Pages) with different Layout which will trigger in a Single form. Below Image will give you more details:

SF_Page1.png

 

 

 

 

 

In the above Image you can see 5 Pages are created with different Page Layout (Portrait / Landscape).
Five Main windows are created which will trigger based on the Output type.

 

 

 

Step 2: Create the Text Field inside the Main Window :
                                   Create the Text Field which you want to show in Output, as this is demo I have created single text field which will displayed in the output. You can put the complete logic based on the Business requirement.Below is the snapshot of it:

p1.png    p2.png
p3.png        p4.png
p5.png

 

 

Step 3: Logic for triggering the respective page:
                                   In this step I can show you how different pages can be triggered based on the input you have given. Based on the Interface Variable (example - Output Type) we can trigger the respective page. Below is the example for the same.
Example: If requirement is to show the respective Page details based on the output type:


OutTypePage
P1FORM1
P2FORM2
P3FORM3
P4FORM4
P5FORM5

 

To get this requirement we need to add Logic in the INITIALIZATION TAB of the Global Definition. Logic is as follows:  

    CASE gv_out.
        WHEN 'P1'. 
              CONTROL_PARAMETERS-startpage = 'FORM1'.
         WHEN 'P2'.
               CONTROL_PARAMETERS-startpage = 'FORM2'.
         WHEN 'P3'.
               CONTROL_PARAMETERS-startpage = 'FORM3'.
         WHEN 'P4'.
               CONTROL_PARAMETERS-startpage = 'FORM4'.
         WHEN 'P5'. 
               CONTROL_PARAMETERS-startpage = 'FORM5'.
   ENDCASE.
In the above Logic GV_OUT  is the Output type variable which is coming from as an input to the Smartform.

CONTROL_PARAMETERS is the default Interface field in the Smartform.
This output type (GV_OUT)  will be defined in the FORM INTERFACE.



 

Step 4: Output :

 

               Based on the input give to the Page (form) will be triggered, below are the outputs;

 

1. If P1 is the Input to the form, output will be:

 

 

               Output1.png

 

 

 

2. If P2 is the Input to the form, output will be:

 

 

          Output2.png
3. If P3 is the Input to the form, output will be:
           Output3.png
      
4. If P4 is the Input to the form, output will be:

 

         Output4.png
5. If P5 is the Input to the form, output will be:
               Output5.png

 


Conclusion:

          At last we are able to get multiple forms by triggering a Single Smart form. As we also see at a Single point of Time Only 1 form / page is getting triggered so there are Performance issue.
Also if your data are large and it overflowing you can create the NEXT PAGE of each one of the above 5 pages. Need to assign the NEXT page to the respective FORMS (Page).
Note: - Things that need to take care is that Main Window of each Page should be of Same Width.
Keep Learning

Stay Awesome
   Romit Raina

 

 

 

 

Creating Smartform output as PDF format in Spool/send any PDF file output to spool in backend:

$
0
0

Creating Smartform output as PDF format in Spool/send any PDF file output to
spool in backend:

 

 

This is required mostly when file size is more in SAP SPOOL
due to that printing might get delayed.

 

 

File size would be more when we are using more images in smartform
and also using pre-printed images. Sometimes it is must and should require
preprinted images in smartform, so we could not remove that from the smartform,
hence in this case we can go ahead with this method.

 

 

Even sometimes there is a requirement to pick the file from
presentation server/Any directory of application server/via some web based pdf
forms(http links), if we have to send those pdf files to spool in background to
generate spool request in pdf format we can go ahead with this code.

 

 

I have searched many links but I did not find any link to
send pdf output to spool in PDF format not in OTF format. Hence sharing this.

 

Below steps are required to generate the spool request in PDF format.

 

 

  1. After getting OTF data from smatform, convert it to
    pdf using “Convert_OTF” FM.
  2. Again convert this pdf output to xstring using below
    code.
  3. From step 2 pass this xstring internal table to
    spool using "ADS_CREATE_PDF_SPOOLJOB" FM.

Here we have to note one point i.e SAP Printer name which we are passing should support
PDF type else we will get error
. For this printer settings or configuration we have to
contact BASIS team.

 

Please find the below code regarding this:

 

 

REPORT ztest_pdffile_1.


DATA: cs_return        TYPE ssfcrescl.
DATA: formname TYPE tdsfname VALUE 'ZTEST_TEST123',

      fmname 
TYPE rs38l_fnam.
DATA:      lc_pdf TYPE sopcklsti1-doc_type VALUE 'PDF',

            gt_otf
TYPE STANDARD TABLE OF itcoo.
DATAct_tline TYPE TABLE OF tline,

      cs_tline
TYPE tline.
DATA: op_option TYPE ssfctrlop.
* ->Get smartform function module name
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

 
EXPORTING

    formname
= formname
*  VARIANT  = ' '
*  DIRECT_CALL              = ' '

 
IMPORTING

    fm_name 
= fmname
* EXCEPTIONS
*  NO_FORM  = 1
*  NO_FUNCTION_MODULE      = 2
*  OTHERS  = 3

 
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

op_option
-getotf = 'X'.

op_option
-no_dialog = 'X'.

op_option
-preview = space.
* -> Call smartform
CALL FUNCTION fmname

 
EXPORTING
*  ARCHIVE_INDEX      =
*  ARCHIVE_INDEX_TAB  =
*  ARCHIVE_PARAMETERS =

    control_parameters
= op_option
*  MAIL_APPL_OBJ      =
*  MAIL_RECIPIENT    =
*  MAIL_SENDER        =
*  OUTPUT_OPTIONS    =
*  USER_SETTINGS      = 'X'

 
IMPORTING

    job_output_info   
= cs_return.
*->Convert OTF output to PDF

gt_otf[]
= cs_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'

 
EXPORTING

   
format                = lc_pdf

    max_linewidth       
= 134
*  IMPORTING
*  bin_filesize          = lv_bin_size

 
TABLES

    otf                 
= gt_otf

   
lines                = ct_tline

 
EXCEPTIONS

    err_max_linewidth   
= 1

    err_format           
= 2

    err_conv_not_possible
= 3

    err_bad_otf         
= 4

   
OTHERS                = 5.
* ->Convert PDF output to XSTRING
DATA: lv_pdfsource TYPE xstring.
FIELD-SYMBOLS:<p> TYPE x. " <p> type any.
LOOP AT ct_tline INTO cs_tline.

 
ASSIGN cs_tline TO <p> CASTING TYPE x.



 
CONCATENATE lv_pdfsource <p> INTO lv_pdfsource IN BYTE MODE.
ENDLOOP.
* ->Create spool request in PDF format
CALL FUNCTION 'ADS_CREATE_PDF_SPOOLJOB'

 
EXPORTING

    printer 
= 'LOCL'            "Printer name supporting PDF device type
*  DEST    =

    pages   
= 1

    pdf_data
= lv_pdfsource        "XSTRING internal table
*  NAME    =
*  SUFFIX1  =
*  SUFFIX2  =
*  COPIES  =
*  PRIO    =

    IMMEDIATE_PRINT       
= 'X'
*  AUTO_DELETE            =
*  TITLELINE              =
*  RECEIVER =
*  DIVISION =
*  AUTHORITY              =
*  LIFETIME = '0'
* IMPORTING
*  SPOOLID  =
* EXCEPTIONS
*  NO_DATA  = 1
*  NOT_PDF  = 2
*  WRONG_DEVTYPE          = 3
*  OPERATION_FAILED        = 4
*  CANNOT_WRITE_FILE      = 5
*  DEVICE_MISSING          = 6
*  NO_SUCH_DEVICE          = 7
*  OTHERS  = 8

 
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

 

Please find the attached document.


Providing Document (Word Document/Excel/PDF file/any images) as User Guide in Custom Programs:

$
0
0

Providing Document (Word Document/Excel/PDF file/any images) as User Guide in Custom
Programs:

 

 

This requirement is useful when user want to provide MS Word /Excel/ PDF/Any image
itself as a User guide in selection screen of Custom Program.

 

 

This requirement can be achieved using BDS (Business Document Service) Concept in ABAP. Below
are the steps needed to follow:

 

 

  1. Upload file in OAOR tcode.
  2. Use "BDS_BUSINESSDOCUMENT_GET_URL" FM to read uploaded document in step 1.
  3. Use "BDS_DOCUMENT_DISPLAY" FM to open this document.

find the attached document for more details and coding part.

Viewing all 29 articles
Browse latest View live


Latest Images

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