SAP & Oracle partner and support companies

Loading

SAP

Tool for GOS attachment from one SAP system to another SAP system

1

Another organization (let’s say XYZ, which is also in SAP) was acquired by your association (let’s say Shy, which is in SAP). The design calls for a field-tested approach that cycles from XYZ to Hesitant and stacks all the information. They must thus establish the links between XYZ business objects and related business objects in the Bashful framework. Tool for GOS attachment from one SAP system to another SAP system.

This basic instrument would transfer any connections (pdf, txt, xls, xml and so on) from source sap framework to target sap framework for all business object types.

Tool for GOS attachment from one SAP system to another SAP system

Stage 1
Plan document with Target Items (PO/PR/Merchant/Materials/Agreements and so on) and comparing Source Articles. Make a point to have comparing driving zeroes for every one of the items. Model PR would have absolute 10 characters; materials would have all out 18 characters, the seller would have complete 10 characters with driving zeroes and so on.

The following is a model record (xls) of Procurement Req from Shy and XYZ framework.

5

Step 2
Execute program Z_GOS_PREPARE_FILE in target system.

2

Step 3
Execute program Z_GOS_ATTACHMENT in target system.

3
4

Common Business Objects

Pur Req  = BUS2105      Material = BUS1001 or BUS1001006
Pur Ord  = BUS2012      Vendor  = LFA1   Contract = BUS2014  etc

Step 4
Validation for our example:

Go to ME53N for Buy Order in source Framework

6

Go to ME53N for Buy Demand in target Framework

7

ABAPer would be more inspired by the code to accomplish the above functionalities.
Kindly find the functioning code joined in four documents. If it’s not too much trouble, click the connection on the right.

Real Time Exchange Rate with Real Time Data Using Yahoo Finance API

Programs:
1) Program to prepare the input file.     z_gos_prepare_file
2) Main program for attachments.          z_gos_attachment

Function Modules:

1) RFC FM in source (XYZ) system.    z_get_xyz_gos_attachment_rfc
2) RFC FM in target (COY) system.    z_gos_attach_to_coy_rfc

Kindly note: in the Fundamental program (in PERFORM get_rfc_name), you really want to put the RFC name of your framework Being developed, Quality and Creation framework separately.

YOU MAY LIKE THIS

Unleashing the Power of Search Help Exit in SAP ABAP

Best Practices for SAP Cloud Platform Development: A Comprehensive Guide

SAP ABAP Online Training: Advanced Business Application

SAP

Sample program to attach any file from application server to any Business Object

ABAP GOS attachment from application server Let’s get started on Sample program to attach any file from the application server to any Business Object.

* Sample program to attach documents to any business object
REPORT z_gos_attachment NO STANDARD PAGE HEADING
LINE-COUNT 132.
*———————————————————————*
* SELECTION SCREEN                                                    *
*———————————————————————*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file   TYPE localfile,      ” Application File Path
p_objid  TYPE swo_typeid,               ” Any object like material no./vendor
“/customer/po/pr etc
p_bo     TYPE swo_objtyp.                ” Business object like LFA1 for vendor
SELECTION-SCREEN END OF BLOCK b1.
DATA:
li_content   TYPE  STANDARD TABLE OF soli,
li_objhead   TYPE STANDARD TABLE OF soli,
lwa_folmem_k TYPE sofmk,
lwa_note     TYPE borident,
lwa_object   TYPE borident,
lwa_obj_id   TYPE soodk,
lwa_content  TYPE soli,
lwa_fol_id   TYPE soodk,
lwa_obj_data TYPE sood1,
lv_ep_note   TYPE borident-objkey,
lv_lifnr     TYPE lifnr,
lv_file      TYPE string,
lv_filename  TYPE c LENGTH 100, ” file name and ext
lv_extension TYPE c LENGTH 4. ” extension only
*   Refresh data
REFRESH: li_content[], li_objhead[].

*   Open corresponding DMS files
OPEN DATASET p_file FOR INPUT IN BINARY MODE.
IF sy-subrc EQ 0.
WHILE sy-subrc = 0.
READ DATASET p_file INTO lwa_content.
* Do not put Sy-subrc eq 0 here. Please add the last line of the file,
* though sy-subrc may fail
APPEND  lwa_content TO li_content.
ENDWHILE.
* Close file
CLOSE DATASET p_file.
* In this example we are attaching in Vendor.
* Converting according to your requirement.. For example for Material,
* it should be 18 chars
* Convert Vendor
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
input  = p_objid
IMPORTING
output = lv_lifnr.

Advance SAPUI5 – Integration of Google Maps JavaScript API with SAPUI5 App

* Convert to BIN
CALL FUNCTION ‘SO_CONVERT_CONTENTS_BIN’
EXPORTING
it_contents_bin = li_content[]
IMPORTING
et_contents_bin = li_content[].

* Get folder id
CALL FUNCTION ‘SO_FOLDER_ROOT_ID_GET’
EXPORTING
region                = ‘B’
IMPORTING
folder_id             = lwa_fol_id
EXCEPTIONS
communication_failure = 1
owner_not_exist       = 2
system_failure        = 3
x_error               = 4
OTHERS                = 5.
* Sy-subrc check not required
* Keeping file in string data type
lv_file = p_file.
* You may not need this step. But  no harm in adding this
* Get file name and extension
CALL FUNCTION ‘CH_SPLIT_FILENAME’
EXPORTING
complete_filename = lv_file
IMPORTING
extension         = lv_extension
name_with_ext     = lv_filename
EXCEPTIONS
invalid_drive     = 1
invalid_path      = 2
OTHERS            = 3.
IF sy-subrc EQ 0.
* Object header
CLEAR lwa_content.
CONCATENATE ‘&SO_FILENAME=’ lv_filename INTO lwa_content.
APPEND lwa_content TO li_objhead.
CLEAR lwa_content.
ENDIF.

lwa_object-objkey  = lv_lifnr.
* For example, business object name for PO is BUS2012,
* business object for PR is BUS2105,
* business object for Vendor is LFA1 etc
lwa_object-objtype = p_bo.
*        lwa_object-logsys  = lv_logical_system.

lwa_obj_data-objsns = ‘O’.
lwa_obj_data-objla = sy-langu.
lwa_obj_data-objdes = ‘Attachment by Raju Shrestha’.  .
lwa_obj_data-file_ext = lv_extension.

TRANSLATE lwa_obj_data-file_ext TO UPPER CASE.
* This is very important step. If your object size does not match with the input
* file size, then your object might get attached, but it will show error while you
* try to open it.
* If you have a way, where you can read the input file size directly, then assign
* it directly else, use the below formula
lwa_obj_data-objlen =  lines( li_content ) * 255.

* Insert data
CALL FUNCTION ‘SO_OBJECT_INSERT’
EXPORTING
folder_id                  = lwa_fol_id
object_type                = ‘EXT’
object_hd_change           = lwa_obj_data
IMPORTING
object_id                  = lwa_obj_id
TABLES
objhead                    = li_objhead
objcont                    = li_content
EXCEPTIONS
active_user_not_exist      = 1
communication_failure      = 2
component_not_available    = 3
dl_name_exist              = 4
folder_not_exist           = 5
folder_no_authorization    = 6
object_type_not_exist      = 7
operation_no_authorization = 8
owner_not_exist            = 9
parameter_error            = 10
substitute_not_active      = 11
substitute_not_defined     = 12
system_failure             = 13
x_error                    = 14
OTHERS                     = 15.
IF sy-subrc = 0 AND lwa_object-objkey IS NOT INITIAL.
lwa_folmem_k-foltp = lwa_fol_id-objtp.
lwa_folmem_k-folyr = lwa_fol_id-objyr.
lwa_folmem_k-folno = lwa_fol_id-objno.

* Please note: lwa_fol_id and lwa_obj_id are different work areas

lwa_folmem_k-doctp = lwa_obj_id-objtp.
lwa_folmem_k-docyr = lwa_obj_id-objyr.
lwa_folmem_k-docno = lwa_obj_id-objno.

lv_ep_note = lwa_folmem_k.
lwa_note-objtype = ‘MESSAGE’.
*          lwa_note-logsys    = lv_logical_system.
lwa_note-objkey = lv_ep_note.

* Link it
CALL FUNCTION ‘BINARY_RELATION_CREATE_COMMIT’
EXPORTING
obj_rolea      = lwa_object
obj_roleb      = lwa_note
relationtype   = ‘ATTA’
EXCEPTIONS
no_model       = 1
internal_error = 2
unknown        = 3
OTHERS         = 4.
IF sy-subrc EQ 0.
* Commit it
COMMIT WORK.
WRITE:/ ‘Attached successfully’.
ENDIF.
ELSE.
MESSAGE ‘Error while opening file’ TYPE ‘I’.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.

YOU MAY LIKE THIS

Steampunk Chronicles: Navigating the Cloud with SAP BTP ABAP Environment

Tips for Building Custom SAP Applications: A Comprehensive Guide

SAP ABAP on HANA Interview Questions: Mastering the Essentials

SAP

Table to check whether a business object has any GOS attachment or not

How can I determine if a business object has a GOS attachment? We would really like to know how many GOS connections are there in Buy Requests, Buy Demands, Merchants, and so on. Using the GOS relationship table “SRGBTBREL” is the simplest way to locate this.

Proceed to SE16(N) and provide the name of the business object in the TYPEID_A (Kind of Articles) box. For example, if the business object name is BUS2012 for the PO, BUS2105, LFA1 for the Seller, 1001006 for the Material, and so on, you can click Execute to view the rundown or click Number of Passages to view the number of connections in that business object. How can I determine if a business object has a GOS attachment?

Selective Handling of the Buttons in ALV Grid Toolbar

You can get the rundown of business object in exchange SWO1.

On the off chance that for reasons unknown, you can’t sort out the business object in exchange SWO1, then the most straightforward method for finding the business object is by going to the exchange (say MM02, ME22N or XK02 and so on) for the article you are intrigued and connect one archive and save it. Presently take that article number and go to table SRGBTBREL and enter the material/po/merchant and so on in field INSTID_A with all driving zeroes. You will get the business object name in field TYPEID_A.

YOU MAY LIKE THIS

SAP ABAP on HANA

How to find badi in sap abap ?

Fiori App – An Introduction from an ABAPer

SAP

SAP Cloud Platform Integration (CPI) Part 23 – Step-by-Step Guide to Mail Adapter Configuration with Attachments

1. Overview on Mail Adapter

Prior to proceeding with SAP Cloud Platform Integration (CPI) Part 23: Detailed Instructions for Configuring Mail Adapters with Attachments. Let’s quickly go over the Mail Adapter. An extensive set of tools and capabilities for coordinating various frameworks and applications inside an organization is provided by SAP CPI (SAP Cloud Stage Mix). The Mail Connector, which enables regular integration with email features and facilitates the sharing of data and relationships, is one of SAP CPI’s key features.

The SAP CPI Mail Connector serves as a bridge between the joining stage and email frameworks like as Gmail, Microsoft Trade, or another SMTP/POP3-compatible mail server. As part of scenarios involving reconciliation, it provides the ability to send and receive messages along with their connections.

Here are a few critical viewpoints and capacities of the SAP CPI Mail Connector: SAP Cloud Platform Integration (CPI) Part 23 – Step-by-Step Guide to Mail Adapter Configuration with Attachments

Configuration:

The Mail Connector can be effortlessly arranged inside SAP CPI utilizing the online incorporation stream proofreader. Directors can characterize settings, for example, mail server subtleties, confirmation certifications, email designs (e.g., plain text or HTML), and connection taking care of choices.

Email Sending:

With the Mail Connector, SAP CPI can send messages from combination streams to outer beneficiaries or interior post boxes. It upholds different email credits like source, recipient(s), subject, body, and need. Connections can likewise be incorporated by indicating the record area or giving the document content straightforwardly inside the combination stream.

Email Receiving:

The Mail Connector permits SAP CPI to get approaching messages and cycle their items. It upholds the recovery of email credits like source, recipient(s), subject, body, and connections. Joining streams can be set off in view of the appearance of new messages, empowering robotization and reconciliation with different frameworks.

Attachment Handling:

The Mail Connector works with the treatment of email connections inside SAP CPI. Connections can be removed from approaching messages and handled by the incorporation stream’s prerequisites. They can be saved to nearby registries, changed, or sent to different frameworks on a case by case basis.

Error Handling and Monitoring:

SAP CPI gives vigorous mistake taking care of and checking abilities for the Mail Connector. It permits executives to follow the situation with email handling, screen approaching and active messages, and handle special cases or disappointments during incorporation streams including the Mail Connector.

2. IFlow Setup

The SAP CPI Mail Connector doesn’t uphold demand answer usefulness essentially in light of the nonconcurrent idea of email correspondence.

While utilizing the Mail Connector, the correspondence between the joining stream in SAP CPI and the email server follows a nonconcurrent design. The combination stream can set off the sending of an email or tune in for approaching messages, however it doesn’t keep an immediate, simultaneous association with the email server.

Subsequently, use SEND range capability for email situations.

As to mail connector properties:

Address – SMTP mail address

Intermediary type – In the event that its through cloud connector, notice on-premise or, in all likelihood Web.

Area ID – of cloud connector

Assurance – Off/STARTTLS Required/STARTTLS Discretionary

Validation – None/Plain Username Secret word/Encoded Username Secret key

Under the handling tab,

From – Email From

To – Email To

Cc/Bcc

Subject – Mail subject. Here we can specify dynamic properties/header which can stream at runtime as displayed beneath.

Mail Body – We can pass the approaching payload as mail body like underneath or design a mail body according to prerequisite.

Body-Emulate type – The substance sort of the body segment. In the event that its Text/HTML, assuming there are any html components, it would be changed over. To send all things considered, pick Message/Plain. There are numerous different choices moreover. Go ahead and investigate.

Body Encoding – UTF-8

For Mail connections,

SAP has given 2 choices. We can make a connection by passing the header content or the body content.

We can find in the underneath picture, where we are passing the stacktrace header (which we set in past satisfied modifier step, ${exception.stacktrace}). Notice the name of the connection too.

Add Message connections – Assuming there are any connections sent by the shipper and the equivalent must be communicated to the recipient, then, at that point, this choice ought to be empowered.

Content exchange Encoding – Programmed

Overall Setup:

Mail:

By along these lines, we can design the mail connector and use it in IFlow. Gratitude for perusing this blog. Blissful learning!

YOU MAY BE INTERESTED IN

10 Real-World SAP ABAP Programming Examples (with Code!)

SAP ABAP vs SAP Basis

Top SAP ABAP Interview Questions (2024)

SAP

How to Send Custom Purchase Order Form Directly to the Vendor?

Let’s look at some concrete methods on how to send a custom purchase order form straight to the vendor. This is the cycle stream to achieve the equivalent.

1. Make a Result Type for the Buy Request with ‘Outer Send’ medium in ME22N

2. Select the Result Type and go to Additional Information.
Select either ‘Send with application own exchange’ to have the choice to audit the report prior to sending or select ‘Send Quickly’ to send email straightforwardly on Save.

3. To save the result type and start the email, click Save.
Assuming you choose “Send with application own exchange,” to initiate the email, navigate to ME9F – > Open the record – > Select the PO and snap Result Message.


Assuming you picked ‘Send Right away’, email would set off upon save. Go to SOST to see email set off.

Detailed Steps :

1. Go to NACE transaction to create a custom output type and assign your PO form and its program in ‘Processing Routine’

2. Add outer send as ‘Medium’, your zprogram’s name in ‘Program’, a subroutine in your zprogram in ‘Program’s Structure Schedule’, your PO structure’s name in ‘PDF/Smartform Structure’ and pdf in ‘Type’

or then again you can utilize Standard PO structure in light of your necessity or need.

3. Make a custom program to set off PO structure and join it to an email to the seller.
The rationale is to set off PO structure’s FM and get the PO structure information from the FM’s Bringing in boundaries, convert it to a paired table and add it as connection to the email. See the code underneath

You can also read for:- Easy Trick to Disable Hold Button in PO (ME21N) using BADI

REPORT zprogram.

INCLUDE rvadtabl. "standardinclude, needed for getting objky from me22n
DATA: gv_fm_name TYPE rs38l_fnam, " FM Name
       gs_fp_docparams TYPE sfpdocparams,
       gs_fp_outputparams TYPE sfpoutputparams.
Data: gv_purdoc_no type ekko-ebeln,
      gv_ldest     type char4.
CONSTANTS : gv_form_name TYPE fpname VALUE 'YOUR CUSTOM FORM NAME',
            gc_printprev type string VALUE 'PREVOUTPUT'.

FORM zsubroutine USING uv_retco LIKE sy-subrc "return code
                           uv_screen TYPE c.
  PERFORM display CHANGING uv_retco. "if output successfull, need to change return code from 999.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form display
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*&      <-- ENT_RETCO
*&---------------------------------------------------------------------*
FORM display  CHANGING cv_retco TYPE sy-subrc.

  IF sy-ucomm = gc_printprev."'PREVOUTPUT'
    gs_fp_outputparams-nodialog = ''.
    gs_fp_outputparams-preview  = abap_true.
  ELSE.
    gs_fp_outputparams-nodialog = abap_true.
    gs_fp_outputparams-preview  = ''.
    gs_fp_outputparams-reqnew   = abap_true.
    gs_fp_outputparams-getpdf   = abap_true.
    IF nast-dimme = abap_true. 
      gs_fp_outputparams-reqimm   = abap_true.
    ENDIF.
  ENDIF.

  DATA: lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
  DATA: lt_message_body TYPE bcsy_text VALUE IS INITIAL,
        lo_document     TYPE REF TO cl_document_bcs VALUE IS INITIAL.
  DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
  DATA: lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL.
  DATA: lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
  DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL,
        lw_return         TYPE bapiret2.

  DATA: lw_formoutput TYPE fpformoutput,
        lt_binarytab  TYPE solix_tab,
        lv_sub        TYPE so_obj_des,
        lv_in_update TYPE i.

  CALL FUNCTION 'FP_JOB_OPEN'
    CHANGING
      ie_outputparams = gs_fp_outputparams
    EXCEPTIONS
      cancel          = 
      usage_error     = 2
      system_error    = 3
      internal_error  = 4
      OTHERS          = 5.
  IF sy-subrc <> 0.

    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
      EXPORTING
        msg_arbgb = sy-msgid
        msg_nr    = sy-msgno
        msg_ty    = sy-msgty
        msg_v1    = sy-msgv1
        msg_v2    = sy-msgv2
        msg_v3    = sy-msgv3
        msg_v4    = sy-msgv4
      EXCEPTIONS
        OTHERS    = 0.

  ENDIF.
**
  TRY.
      CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
        EXPORTING
          i_name     = gv_form_name 
        IMPORTING
          e_funcname = gv_fm_name.
      "Exception handling
    CATCH cx_fp_api_internal.
    CATCH cx_fp_api_repository.
    CATCH cx_fp_api_usage.
  ENDTRY.

  cv_retco = 0.

  gv_purdoc_no = nast-objky. "objky contains purchase doc number

  CALL FUNCTION gv_fm_name 
    EXPORTING
      iv_purdoc_no       = gv_purdoc_no
    IMPORTING
      /1bcdwb/formoutput = lw_formoutput
    EXCEPTIONS
      usage_error        = 1
      system_error       = 2
      internal_error     = 3
      OTHERS             = 4.

  IF sy-subrc = 0.

    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
      EXPORTING
        msg_arbgb = 'ZSCM'
        msg_nr    = '022'
        msg_ty    = 'S'
*       MSG_V1    = TEXT-001
      EXCEPTIONS
        OTHERS    = 0.
  ELSE.

    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
      EXPORTING
        msg_arbgb = sy-msgid
        msg_nr    = sy-msgno
        msg_ty    = sy-msgty
        msg_v1    = sy-msgv1
        msg_v2    = sy-msgv2
        msg_v3    = sy-msgv3
        msg_v4    = sy-msgv4
      EXCEPTIONS
        OTHERS    = 0.

  ENDIF.

  CALL FUNCTION 'FP_JOB_CLOSE'
    EXCEPTIONS
      usage_error    = 1
      system_error   = 2
      internal_error = 3
      OTHERS         = 4.
  IF sy-subrc <> 0.
*   Implement suitable error handling here
  ENDIF.

"Convert Form Output to Binary table to be added as email attachment
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = lw_formoutput-pdf
*     APPEND_TO_TABLE       = ' '
*   IMPORTING
*     OUTPUT_LENGTH         =
    TABLES
      binary_tab = lt_binarytab.

  SELECT SINGLE ekko~ebeln, ekpo~ebelp, ekko~lifnr, ekpo~werks, ekko~bedat FROM ekko
    INNER JOIN ekpo
    ON ekko~ebeln = ekpo~ebeln
    INTO @DATA(lw_povendor)
    WHERE ekko~ebeln = @gv_purdoc_no
      AND ekpo~loekz = ''.

  IF sy-subrc = 0.

    "Here you can create a Custom Table to maintain email data for each Vendor. I am fetching Email To, Email Cc, Email From and Subject Line that is maintained for that PO's vendor

    SELECT SINGLE * FROM zvendoremaildatatable INTO @DATA(lw_vendordetails)
      WHERE lifnr = @lw_povendor-lifnr.
    IF sy-subrc = 0.

      lv_sub = lw_vendordetails-zsubject.
      "You can edit the subject line with PO data dynamically       data(lv_bedat_formatted) = |{ lw_povendor-bedat+4(2) }| && |/| && |{ lw_povendor-bedat+6(2) }|.
      REPLACE FIRST OCCURRENCE OF 'mmdd' IN lv_sub WITH lv_bedat_formatted. "lw_povendor-bedat
      REPLACE FIRST OCCURRENCE OF '&&' IN lv_sub WITH gv_purdoc_no.

      lo_send_request = cl_bcs=>create_persistent( ).

      "Add email body  APPEND 'Thanks,' TO lt_message_body.
       APPEND 'Bhavya Kariwala' TO lt_message_body.

      lo_document = cl_document_bcs=>create_document(
                                      i_type = 'RAW'
                                      i_text = lt_message_body
                                      i_subject = lv_sub ).
      DATA(lv_attachment_name) = |PO#| && |{ gv_purdoc_no }| && | Form|.
      TRY.

          lo_document->add_attachment(
                        EXPORTING
                          i_attachment_type = 'pdf'
                          i_attachment_subject = CONV sood-objdes( lv_attachment_name )
*                   I_ATTACHMENT_SIZE =
*                   I_ATTACHMENT_LANGUAGE = SPACE
*                   I_ATT_CONTENT_TEXT =
*                   I_ATTACHMENT_HEADER =
                          i_att_content_hex = lt_binarytab ).

        CATCH cx_document_bcs INTO lx_document_bcs.

      ENDTRY.

      lo_send_request->set_document( lo_document ).

      "Set sender
      lo_sender = cl_sapuser_bcs=>create( sy-uname ).
      lo_sender = cl_cam_address_bcs=>create_internet_address( CONV adr6-smtp_addr(  lw_vendordetails-zemail_from ) ).

      lo_send_request->set_sender(
                        EXPORTING
                          i_sender = lo_sender ).

      "Set recipient
"I have maintained multiple email addresses for a vendor separated by ';', so it's now been put into an internal table to be looped through.
      SPLIT lw_vendordetails-zemail_to AT ';' INTO TABLE DATA(lt_emailto).
      SPLIT lw_vendordetails-zemail_cc AT ';' INTO TABLE DATA(lt_emailcc).

      LOOP AT lt_emailto INTO DATA(lw_emailto).
*        TRY.
          lo_recipient = cl_cam_address_bcs=>create_internet_address( CONV adr6-smtp_addr( lw_emailto ) ).
          lo_send_request->add_recipient(
                            EXPORTING
                              i_recipient  = lo_recipient                 " Recipient of Message
                            i_express    = abap_true                 " Send As Express Message
*                        i_copy       =                  " Send Copy
*                        i_blind_copy =                  " Send As Blind Copy
*                        i_no_forward =                  " No Forwarding
                          ).
*        CATCH cx_send_req_bcs. " BCS: Send Request Exceptions
*        ENDTRY.
      ENDLOOP.

      LOOP AT lt_emailcc INTO DATA(lw_emailcc).
*        TRY.
            lo_recipient = cl_cam_address_bcs=>create_internet_address( CONV adr6-smtp_addr( lw_emailcc ) ).
            lo_send_request->add_recipient(
                              EXPORTING
                                i_recipient  = lo_recipient                 " Recipient of Message
                              i_express    =  abap_true                " Send As Express Message
                                i_copy       = abap_true                  " Send Copy
*                    i_blind_copy =                  " Send As Blind Copy
*                    i_no_forward =                  " No Forwarding
                            ).
*        CATCH cx_send_req_bcs. " BCS: Send Request Exceptions
*        ENDTRY.
      ENDLOOP.

      "Send email
      lo_send_request->send(
                        EXPORTING
                          i_with_error_screen = 'X'
                        RECEIVING
                          result = lv_sent_to_all ).
"Check to see if email was triggered in UPDATE TASK
      CALL FUNCTION 'TH_IN_UPDATE_TASK'
       IMPORTING
         IN_UPDATE_TASK       = lv_in_update
                .
      IF lv_in_update <> 1.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = abap_true
          IMPORTING
            return = lw_return.
      endif.

    ENDIF.
  ENDIF.
ENDFORM.

4. Furthermore, as consumed in the code above, you can make a table to keep up with Email Information for every Merchant. You can make a Table Upkeep Generator to keep up with sections against every Seller so this interaction can turn out to be more robotized.

Hope you got the How to Send Custom Purchase Order Form Directly to the Vendor?

thanks! have a good day.

YOU MAY LIKE THIS

Is SAP ABAP a High Paying Job?

SAP ABAP Consultant Trainer

Your Definitive Guide to Becoming a SAP ABAP Developer

SAP

Object Oriented Way of Sending an email with PDF as an Attachment

Introduction

Send an email in Apex that includes a PDF attachment (Object Oriented Method of Sending an Email with a PDF Attachment)

The blog post I wrote on the topic of “Item Arranged approach to sending an email from ABAP side” is expanded upon in this one. An object-oriented method for attaching a PDF to an email.

You will also learn how to send an email using an object-oriented method with a PDF attached in this blog post, Object Oriented Way of Sending an Email with PDF as an Attachment. In this case, a SMARTFORM will generate the PDF.

Prerequisite (Object Oriented Way of Sending an email with PDF as an Attachment)

  1. A Smartform – It tends to be an essential smartform with a short message, we simply need it for show reason.
  2. Essential information on involving class CL_BCS for email sending.
  3. A trigger program.

Steps

Create a Smartform with any Z/Y name.

I made with the name “ZTEST_SMARTFORM_ATTACHMENT”. It simply have a short text as beneath:

Create an executable program in SE38.

I made it with the name “ZTEST_EMAIL_WITH_ATTACHMENT”.

DATA DECLARATIONS

(Please excuse for the naming convention used)

CONSTANTS:
lc_sfname TYPE tdsfname VALUE 'ZTEST_SMARTFORM_ATTACHMENT'. "Name of Smartform

"Local Object References
DATA: lo_bcs         TYPE REF TO cl_bcs,
      lo_doc_bcs     TYPE REF TO cl_document_bcs,
      lo_recep       TYPE REF TO if_recipient_bcs,
      lo_sapuser_bcs TYPE REF TO cl_sapuser_bcs,
      lo_cx_bcx      TYPE REF TO cx_bcs.

"Local Internal Tables.
DATA: lt_otfdata        TYPE ssfcrescl,
      lt_binary_content TYPE solix_tab,
      lt_text           TYPE bcsy_text,
      lt_pdf_tab TYPE STANDARD TABLE OF tline,
      lt_otf     TYPE STANDARD TABLE OF itcoo.

"Local Structures
DATA: ls_ctrlop TYPE ssfctrlop,
      ls_outopt TYPE ssfcompop.

"Local Variables
DATA: lv_bin_filesize TYPE so_obj_len,
      lv_sent_to_all  TYPE os_boolean,
      lv_bin_xstr     TYPE xstring,
      lv_fname        TYPE rs38l_fnam,
      lv_string_text  TYPE string.

Get the name of the function module of the SMARTFORM .

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname           = lc_sfname
  IMPORTING
    fm_name            = lv_fname
  EXCEPTIONS
    no_form            = 1
    no_function_module = 2
    OTHERS             = 3.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Fill the Control Parameters, output options and call the FM of your SMARTFORM.

We will get the OTF data generated by the smartform in internal table “lt_otf”.

"Control Parameters
ls_ctrlop-getotf    = 'X'.
ls_ctrlop-no_dialog = 'X'.
ls_ctrlop-preview   = space.

"Output Options
ls_outopt-tdnoprev  = 'X'.
ls_outopt-tddest    = 'LOCL'.
ls_outopt-tdnoprint = 'X'.    "No printing from print preview

CALL FUNCTION lv_fname
  EXPORTING
    control_parameters = ls_ctrlop
    output_options     = ls_outopt
  IMPORTING
    job_output_info    = lt_otfdata
  EXCEPTIONS
    formatting_error   = 1
    internal_error     = 2
    send_error         = 3
    user_canceled      = 4
    OTHERS             = 5.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.


lt_otf[] = lt_otfdata-otfdata[].

Convert OTF Data to XSTRING “lv_bin_xstr”.

CALL FUNCTION 'CONVERT_OTF'
  EXPORTING
    format                = 'PDF'   "PDF to get pdf output
  IMPORTING
    bin_filesize          = lv_bin_filesize
    bin_file              = lv_bin_xstr
  TABLES
    otf                   = lt_otf[]
    lines                 = lt_pdf_tab[]
  EXCEPTIONS
    err_max_linewidth     = 1
    err_format            = 2
    err_conv_not_possible = 3
    OTHERS                = 4.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Convert the XSTRING to Binary table “lt_binary_content”.

***Xstring to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer     = lv_bin_xstr
  TABLES
    binary_tab = lt_binary_content.

Prepare to Send Email

 Create persistent send request

TRY.
*     -------- create persistent send request ------------------------
    lo_bcs = cl_bcs=>create_persistent( ).

Create Email Body

    "Line-1
    CONCATENATE 'Dear Colleague' cl_abap_char_utilities=>newline INTO lv_string_text.
    APPEND lv_string_text TO lt_text.
    CLEAR lv_string_text.
    "Line-2
    CONCATENATE 'Please find attached a test smartform.'
     cl_abap_char_utilities=>newline INTO lv_string_text.
    APPEND lv_string_text TO lt_text.
    CLEAR lv_string_text.
    "Line-3
    APPEND 'Best Regards,' TO lt_text.
    "Line-4
    APPEND 'Systems Administrator.' TO lt_text.

Create Email

*---------------------------------------------------------------------
*-----------------&      Create Document     *------------------------
*---------------------------------------------------------------------
    lo_doc_bcs = cl_document_bcs=>create_document(
                    i_type    = 'RAW'
                    i_text    = lt_text[]
                    i_length  = '12'
                    i_subject = 'Test Email' ).   "Subject of the Email

Add attachment to document and Add document to send request

The interior table “lt_binary_content” contains the substance of our connection.

*---------------------------------------------------------------------
*-----------------&   Add attachment to document     *----------------
*---------------------------------------------------------------------
*     BCS expects document content here e.g. from document upload
*     binary_content = ...
    CALL METHOD lo_doc_bcs->add_attachment
      EXPORTING
        i_attachment_type    = 'PDF'
        i_attachment_size    = lv_bin_filesize
        i_attachment_subject = 'Test Email'
        i_att_content_hex    = lt_binary_content.

*     add document to send request
    CALL METHOD lo_bcs->set_document( lo_doc_bcs ).

you can also read for:- AI Tools for Email marketing

Set Sender

Note: this is fundamental provided that you need to set the source unique in relation to genuine client (SY-UNAME). In any case source is set consequently with genuine client.
FYI. I have remarked the code in my program.

*---------------------------------------------------------------------
*------------------------&   Set Sender     *-------------------------
*---------------------------------------------------------------------
*    lo_sapuser_bcs = cl_sapuser_bcs=>create( sy-uname ).
*    CALL METHOD lo_bcs->set_sender
*      EXPORTING
*        i_sender = lo_sapuser_bcs.

Add recipient (e–mail address)

You can involve various beneficiaries too.

    lo_recep = cl_cam_address_bcs=>create_internet_address(
                                                'test@test123.com' ).

"Add recipient with its respective attributes to send request
    CALL METHOD lo_bcs->add_recipient
      EXPORTING
        i_recipient = lo_recep
        i_express   = 'X'.

Set Send Immediately

You can set this to promptly send your email.

CALL METHOD lo_bcs->set_send_immediately
      EXPORTING
        i_send_immediately = 'X'.

Send the Email

*---------------------------------------------------------------------
*-----------------&   Send the email    *-----------------------------
*---------------------------------------------------------------------
    CALL METHOD lo_bcs->send(
      EXPORTING
        i_with_error_screen = 'X'
      RECEIVING
        result              = lv_sent_to_all ).

    IF lv_sent_to_all IS NOT INITIAL.
      COMMIT WORK.
    ENDIF.


*---------------------------------------------------------------------
*-----------------&   Exception Handling     *------------------------
*---------------------------------------------------------------------
  CATCH cx_bcs INTO lo_cx_bcx.
    "Appropriate Exception Handling
    WRITE: 'Exception:', lo_cx_bcx->error_type.
ENDTRY.

Conclusion

This is one of the approach to sending an email with a PDF connection.

For any issues, enhancements, augmentations or some other worries, kindly go ahead and get in touch with us.

I look forward for your criticism and ideas.

Continue to learn!! Continue to get to the next level!!

YOU MAY LIKE THIS

Epic Evolution of ABAP Programming

Mastering the Basics of SAP ABAP: A Comprehensive Guide

How to check your custom ABAP code for SAP BTP ABAP Environment

SAP

SOLMAN—Understanding Attribute Context & Action Profile in Mail Forms

I explained in my last instructive exercise how to improve the conventional SOLMAN Mail Structures with additional attributes (fields and items) before moving on to the SOLMAN – Understanding Attribute Context & Action Profile in Mail Forms. Many readers wanted to know how to find the correct Credit Setting and Trait Classification.

Let me begin by discussing the specifics.

Quality assists with making customized content via the Post office Structures. Let’s get start on SOLMAN – Understanding Attribute Context & Action Profile in Mail Forms.

What are Attribute Contexts in Mail Forms?

Characteristic Settings determine which ascribes are available in Mail Structures (you can anticipate them to be fields or slot holders). Standard characteristic setting will be available in Mail Structures, of course. We can also describe other custom property settings. As a result, we can include our own traits. In the end, during custom enhancements, we can select a customized/custom property setting instead of the default one using the Post office Structures.

Real Time Exchange Rate with Real Time Data Using Yahoo Finance API

How can we check the list of the attribute context available?

Execute SM_CRM Transaction. It opens a webpage link home screen, where we can see Service Operations.

Click on Mail Forms.

It will take you to the Search: Mail Forms screen.

Try not to be frightened to see the rundown of Mail Structures. Standard Mail Structures are given by SAP and the custom Mail Structures were made by SOLMAN Advisors. ABAP engineers don’t have to stress the way things were made (despite the fact that, figuring out how to make doesn’t hurt).

For our example we will select “Z_MESSAGE_PROCESSOR”.

Check the Attribute Context. It is a standard Context.

We can click the drop down to check the different Attribute Contexts available.

For our prerequisites in the past instructional exercise, they have chosen Administration Solicitation Ascribes. This will give us standard construction and fields naturally.

Click on Attribute Tab to check the Attribute Category.

Click the Attribute Category and check the different types of Attributes available.

For our prerequisite we picked SRQ Standard Ascribes which is utilized for the Assistance Sends. This class gives us the construction and rundown of accessible fields under it as displayed beneath.

Quality Classification is an assortment of classifications, which contains a rundown of classes accessible.

These classifications hold construction and fields which can be utilized for the mail structures.

  • Business partner
  • Marketing attributes
  • Campaigns
  • System attributes
  • Additional fields

Additional Brownie Points. ?

How to Create or Add Custom Attribute Context?

As educated over, the SOLMAN Specialists do this errand. ABAPers need not stress. Yet, ABAPer attempt to be Handyman. Thus, here we go. Regardless of whether we can’t dominate, no damage in knowing it. ?

Go to SPRO – > Client Relationship The board – > Advertising – > Showcasing Arranging and Mission The executives – > Customized Mail – > Keep up with Quality Settings for Mail Structures.

Time to maintain the Action Profile and Actions.

T-Code – SPPFCADM

We have maintained it for CRM_ORDER.

Select CRM_ORDER and click on Define Action Profile and Actions.

Search for your Activity Profile. We have replicated SMIN_STD standard Activity Profile to ZMIN_STD and tweaked.

ABAPers.. you are stepping an in the perilous area. Sssshhhhhh .. try not to tell your SOLMAN Advisor.

Select ZMIN_STD and click on Activity Definition.

List of Action Definitions are available.

Select the specific activity definition and snap on Handling Type.

Here you find the Allowed Handling Sorts of Activity. For us it is Technique Call and we likewise have the Strategy name for example SEND_MAIL_WITH_MAIL_FORMS.

Click on the showcase Execution button (featured in red circle above). This is the execution class which calls the Activity Technique.

How to find the Structure to be Enhanced in Mail Forms?

In the last article we uncovered that SRQ Standard Credits utilizes the standard design “CRMS_SRQM_GEN_FIELDS” and we expected to add another field in this construction to meet our prerequisite. In any case, one peruser inquired, “How could we realize this construction name?”

To respond to that inquiry, we want to thoroughly search in to the BADI we executed. BADI name CRM_IM_ADD_DATA_BADI. How we found the BADI is one more subject to talk about another day.

In the BADI Execution, go to Strategy CRM_IM_BPSELE.

At first, when there is no code in the technique, you may just put order “BREAK-POINT”. Or on the other hand you may just place a Circle AT CT_ATT_VALUES INTO WA_VALUES. ENDLOOP. Furthermore, put a break point.

If it’s not too much trouble, note: Put an Outside Break Point on the off chance that your SM_CRM utilizes the WebUI.

Really take a look at the segments in CT_ATT_VALUES. CRMS_SRQM_GEN_FIELDS is the design which will house the new fields. Presently mess with the design and pass anything that ascribes the business requests. You have turned into a Genie for them.

We are finished. I attempted to show every one of the abilities required for upgrading the SOLMAN Mail Structures. You additionally know not many stunts which the SOLMAN Experts don’t uncover. In this way, next time you want to send an additional quality, you can behave like a Genius and get it conveyed.

YOU MAY LIKE THIS

Building Cloud-Native ABAP Applications: A Guide to Modern SAP Development

Parallel cursor in SAP ABAP

How to Create RAP business events in SAP BTP ABAP Environment ?

SAP

SOLMAN—Mail Forms Custom Enhancement Guide

SOLMAN is a very powerful framework. It is used by many groups for venture planning and documentation. Many clients alter the executives’ framework and utilize it for transportation. We explained how to create a custom Fiori application for changing the board in Solman in one of our previous posts. SOLMAN: Custom Enhancement Guide for Mail Forms.

Today, we will investigate the Mail Structures which is utilized in the episode the executives region. In this instructional exercise, SOLMAN—Mail Forms Custom Enhancement Guide, we will figure out how to add another uniquely documented in MailForm Trait classification for Quality setting.

What are Mail Forms? SOLMAN—Mail Forms Custom Enhancement Guide..

Let me try to make sense of it in as simple a sentence as possible. We create episodes or tickets in the Solman framework based on customer requests. There is a programmed mail that will be triggered whenever something happens or is altered in the framework. With the aid of mail structures, this notice is completed.

Get Latitude and Longitude of any place using Google Map API in SAP

Who gets the mail from SOLMAN? (SOLMAN – Mail Forms Custom Enhancement Guide)

All the stakeholders of the particular incident/ticket are supposed to receive the mail. In short the below users receive the mail:

  1. Message processor
  2. Contact person
  3. Reported by

What is the t-code to create Incident in SOLMAN?

SM_CRM is the exchange utilized for making Occurrences.

Contingent upon the SOLMAN settings, SM_CRM Arrangement Supervisor IT Administration The board will open in SAP GUI meeting or it will open in discrete page connect in web pioneer (chrome or other default internet browsers).

Once the incident is created, it would look like below.

Mail will be delivered to concern person or team.

Example of a real mail for the generated incident.

Mail will be set off in above design.

In any case, clients are an alternate variety of human. They would as a rule be not happy with what the standard SAP give. For our situation, the business necessity was to have arrangement to send Long Message Log with the verifiable refreshed toward the finish of the mail.

Specialists all through the world flourish due to improvement and customization demands like this. We want to thank our clients for such learning and working open doors. . I’m not kidding around.

An example log of the episode.

However, arrangement isn’t straight forward.

For ABAP designers, the sky is the limit. You put a necessity, you would get an answer. In some cases the plan is enhanced and smooth while on occasion the engineers take a filthy course to meet the business need.

For our situation, we can accomplished this by utilizing Mail Structures with some ABAP improvements.

Accepting, we have finished our improvement. The occurrence alarms after complete of the change would like beneath with expansion of Text log (Long portrayal).

Have patience.  I will show you step by step, how to enhance the Mail Forms in SOLMAN.

Step 1

For our model, the custom field is added for Characteristic Setting “Administration Solicitation Ascribes”.

This Assistance Solicitation Ascribes utilizes administrations Quality Classification “SRQ Standard Credits”.

SRQ Standard Credits thusly utilizes the standard construction “CRMS_SRQM_GEN_FIELDS”.

In the design CRMS_SRQM_GEN_FIELDS, add the expected fields utilizing add structure.

We made the attach structure ZZCRM_SRQM_TEXT_LOG with area ZSTRING and information type String to acknowledge long text values.

Step 2

Once the required field is added to the structure CRMS_SRQM_GEN_FIELDS, go to the t-code SM_CRM.

In the left panel, click on Service Operations (highlighted above).

Now click on Mail Forms and Search for Mail Form ID.

For our case, we are accomplishing for Z_MESSAGE_PROCESSOR. Select the Mail Structure ID you need to improve.

Presently we want to add the custom field at the necessary spot. To add the new spot holder, click on Property as displayed beneath.

In the following screen look for our field, yet here we can’t track down specialized name. We really want to look through in view of the portrayal we provided for the information component. For us the field mark is “Text Log”.

Select the field with Text Log and snap on Supplement button.

Place the new field at the ideal situation as shown beneath.

Step 3

The construction and position of new field is finished. Presently we really want to execute the BADI: “CRM_IM_ADD_DATA_BADI”. This BADI works for Keep up with Extra Credits for Mail Structures Characteristic Settings. It is channel subordinate, so we really want to choose required Property Setting and Type.

In the Property Setting select Assistance Solicitation and Type SQM.

Execute the BADI.

In the strategy CRM_IM_BPSELE, We want to compose our rationale to change the qualities to populate long text values for Text Log.

Fundamentally, we want to change the inward table CT_ATT_VALUES. This interior table have two fields:

  • Name (which holds the names of the additional field via the Post office Structures id).
  • Esteem (which holds the upsides of the fields).

We really want to adjust this table just for the CTT_ATT_VALUES-NAME = “CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG”.

Then alter the CTT_ATT_VALUES-VALUES = “with regarded required data”.

As may be obvious, field Worth Information Type is STRING, this is the explanation while making custom field for Text Log we have involved String as Information Type. You may be enticed to utilize roast 255 and it could work. However, you actually risk shortening the characters assuming they surpass.

Since Text Logs are free texts, it is the most secure wagered to utilize STRING.

How to modify internal table CT_ATT_VALUES?

We want to Circle at CT_ATT_VALUES. As referenced before, we really want to change just for the TEXT LOG field “CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG”.

Underneath code bit can be utilized for reference.

Throughout the entire the Text (Text Log subtleties) we have perused utilizing FM “CRM_DNO_READ_ORDER_TEXT”.

We really want to pass GUID of the Item id (only Occurrence number).

We can get GUID from table TABLE: CRMD_ORDERADM_H

Then loop at LT_ALLTEXTS (which holds the long text).

Here we have added Text Log just for SU01 (Answer), SU99 (Depiction), SUSO (Arrangement). You might investigate and check what different codes you might get for the Text Log.

To peruse the text we really want to utilize the amazingly popular FM”READ_TEXT” and pass Text ID, Language, Name, Item.

These values are readily available in LT_ALLTEXTS.
LT_ALLTEXTS-STXH-TDID
LT_ALLTEXTS-STXH-TDNAME,
Object will be CRM_ORDERH.
Language you know. 

Recover the Text Id depiction from table TTXIT

For Text ID portrayal kindly check underneath screen shot.

Circle the LT_LINE recovered from READ_TEXT FM and alter the CT_ATT_VALUES-Worth.

At the point when we use string all values will be imprinted in single line like underneath.

In any case, you don’t need a grouped passage. You need space and great organization.

How to format the string values?

To stay away from this, we utilize the order Connect and Isolated BY CL_ABAP_CHAR_UTILITIES=>CR_LF. Don’t bother referencing, this order makes new line (it is like return, enter key).

After using CL_ABAP_CHAR_UTILITIES=>CR_LF, the paragraph looks better.

Complete Code:

METHOD if_ex_crm_im_add_data_badi~crm_im_bpsele.
   DATA : lt_alltexts TYPE comt_text_textdata_t.
    DATA : lv_id     TYPE thead-tdid,
          lv_lang   TYPE  thead-tdspras VALUE 'EN',
          lv_name   TYPE thead-tdname,
          lv_object TYPE  thead-tdobject VALUE 'CRM_ORDERH',
          lt_line   TYPE TABLE OF tline, 
          lv_string TYPE string,
          lv_string2 TYPE string,
          lv_string3 TYPE string.
 
 *--> loop the ct_att_values will have all the fields whhich described in mailforms
     LOOP AT ct_att_values ASSIGNING FIELD-SYMBOL(<line>).
 **** change the value for the long text(CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG) field and modify the values with required data ****
       CASE <line>-name.
         WHEN 'CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG'.
 
 *--> Get the HEADER GUID from table CRMD_ORDERADM_H based on CRMS_SRQM_GEN_FIELDS-CRM_SRQM_NUMBER(OBJECT ID)
      READ TABLE ct_att_values INTO DATA(ls_att_value) WITH KEY name = 'CRMS_SRQM_GEN_FIELDS-CRM_SRQM_NUMBER'.
      IF sy-subrc = 0.
      SELECT SINGLE guid FROM crmd_orderadm_h INTO @DATA(lv_guid)
       WHERE object_id = @ls_att_value-value.
 
 *--> get the order text id from FM
      CALL FUNCTION 'CRM_DNO_READ_ORDER_TEXT'
        EXPORTING
         iv_header_guid          = lv_guid
       IMPORTING
         et_alltexts             = lt_alltexts.
 *--> LT_ALLTEXT will contain all the text ids which maintained in incident
      LOOP AT lt_alltexts ASSIGNING FIELD-SYMBOL(<fs_alltexts>).
 *--> Add text ids values only for the SU01(REPLY) SU99(DESCRIPTION) SUSO(SOLUTION)
       IF <fs_alltexts>-stxh-tdid = 'SU01' OR <fs_alltexts>-stxh-tdid = 'SU99' OR <fs_alltexts>-stxh-tdid = 'SUSO'.
 
        lv_id   = <fs_alltexts>-stxh-tdid.
        lv_name = <fs_alltexts>-stxh-tdname.
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
            client                        = sy-mandt
            id                            = lv_id
            language                      = lv_lang
            name                          = lv_name
            object                        = lv_object
          TABLES
            lines                         = lt_line
         EXCEPTIONS
           id                            = 1
           language                      = 2
           name                          = 3
           not_found                     = 4
           object                        = 5
           reference_check               = 6
           wrong_access_to_archive       = 7
           OTHERS                        = 8.
        IF sy-subrc <> 0.
 * Implement suitable error handling here
        ENDIF.
 *--> Get the Text ID description from TTXIT tables
        SELECT SINGLE tdtext FROM ttxit INTO @DATA(lv_desc)
         WHERE tdspras  = @lv_lang
           AND tdobject = @lv_object
           AND tdid     = @<fs_alltexts>-stxh-tdid.
 
 *--> Date
        CONCATENATE <fs_alltexts>-stxh-tdfdate+6(2) <fs_alltexts>-stxh-tdfdate+4(2) <fs_alltexts>-stxh-tdfdate+0(4)
                    INTO DATA(lv_date) SEPARATED BY '.'.
 *--> Time
        CONCATENATE <fs_alltexts>-stxh-tdftime+0(2) <fs_alltexts>-stxh-tdftime+2(2) <fs_alltexts>-stxh-tdftime+4(2)
                    INTO DATA(lv_time) SEPARATED BY ':'.
 *--> Date Time User
        CONCATENATE lv_date lv_time <fs_alltexts>-stxh-tdfuser
                    INTO DATA(lv_date_user) SEPARATED BY space.
 
        CONCATENATE lv_desc lv_date_user INTO lv_string SEPARATED BY cl_abap_char_utilities=>cr_lf.
        LOOP AT lt_line INTO DATA(ls_line).
          CONCATENATE lv_string2 ls_line-tdline INTO lv_string2 SEPARATED BY cl_abap_char_utilities=>cr_lf.
        ENDLOOP.
        CONCATENATE <line>-value lv_string lv_string2 INTO <line>-value SEPARATED BY cl_abap_char_utilities=>cr_lf.
        lv_string3 = '------------------------------------------------------------------------------------------------------'.
        CONCATENATE <line>-value lv_string3 INTO <line>-value SEPARATED BY cl_abap_char_utilities=>cr_lf.
 
        REFRESH lt_line.
        CLEAR : lv_string, lv_string2, lv_string3, ls_line, lv_desc, lv_id,
                lv_name, lv_date_user, lv_string2, lv_date, lv_time.
        ENDIF.
       ENDLOOP. 
      ENDIF.
        ENDCASE. 
     ENDLOOP. 
   ENDMETHOD.

That is all there is to it. You are finished. Presently request that you entrepreneur make the occurrence and get the Message Sign in the email. Advise them to send an appreciation mail for you to your detailing administrator. Remember to exhibit this improvement in your quarterly execution audit meeting with your supervisor. This improvement isn’t no problem. Truly.

On a serious note, I needed to work a few late evenings to make it happen. It could look basic currently in the wake of going through this article. In any case, accept me, it wasn’t so much that that simple when it was relegated to me.

I have attempted to place every one of the subtleties in this instructional exercise. However, assuming you actually feel somewhat unsure, go ahead and put your inquiries in the remarks area. I will try to answer to every single question.

YOU MAY LIKE THIS

ABAP Development Environment in the Cloud

Mastering the Future of SAP Development

Introduction to ABAP on Cloud

SAP

Distribution List in SAP

Let’s examine the SAP Distribution List in more detail. We’re going back to nuts and bolts again. We would focus on SAP’s Dispersion Rundown today. In SAP, we can create a breakdown and send a single email to multiple recipients at the same time, much like we can create an email list in Lotus Notes or Standpoint. Although the dispersion list is a well-known tool in SAP, many of our new hires may find it to be an interesting and useful teaching exercise.

As a result, Conveyance Rundown in SAP can be used in the unlikely event that it becomes necessary to email a group about a particular cycle. SAP Distribution List.

Dissemination list are like SMTP and lessens programming work by and large for informing gathering.

Steps for creation of Distribution List (DL):

  • Tcode for Distribution list is SO23.
  • Click on create button and create your own folder in DL and specify the details as showed.
  • One can set below properties like retention properties etc.

Get Latitude and Longitude of any place using Google Map API in SAP

  • When the envelope is made and individual properties are added according to above preview add the particular email id to whom mail ought to be sent and you are finished making DL.

Different ways to use DL:

Not many of the numerous manners by which the Conveyance Rundown can be utilized is referenced underneath:

  1. One can go to SBWP tcode and select the folder which you have created as part of Distribution List and click on create new document.

Make your message as displayed underneath and tap on send.

Click on send and choose the Appropriation list made by you and tap on send , your mail is sent.

2. Create a custom program which can be used to send email according to your Distribution List.

*&---------------------------------------------------------------------*
*& Report ZYASH_DL
*&---------------------------------------------------------------------*
*& Demo program to send email to Distribution List
*&---------------------------------------------------------------------*
 REPORT zyash_dl.
 "Create a ref of type CL_BCS
 DATA : obj_mail  TYPE REF TO cl_bcs,
        obj_send  TYPE REF TO if_recipient_bcs,
        l_output  TYPE boolean,
        mail_body TYPE bcsy_text.
  TRY.
     obj_mail = cl_bcs=>create_persistent( ).
   CATCH cx_send_req_bcs .
 ENDTRY.
 ** ONE CAN TAKE THE DL AUTOMATICALLY BY PASSING IT THROUGH SELECTION SCREEN AS INPUT PARAMETER
 TRY.
     obj_send ?=  cl_distributionlist_bcs=>getu_persistent( i_dliname = 'ZYASH'
                                                             i_private = ' ' ).
   CATCH cx_address_bcs .
 ENDTRY.
 TRY.
     obj_mail->add_recipient( i_recipient  = obj_send ).
   CATCH cx_send_req_bcs .
 ENDTRY.
 
 "Lets create the message 
 APPEND 'Hi , Please comment if you found this article useful' TO mail_body.
 TRY.
     DATA(l_doc) =   cl_document_bcs=>create_document( i_type        = 'RAW'
                                                    i_subject     = 'Welcome Yash To DL'
                                                    i_sensitivity = 'P'
                                                    i_text        = mail_body ).
   CATCH cx_document_bcs .
 ENDTRY.
 
 TRY.
     obj_mail->set_document( i_document = l_doc ).
   CATCH cx_send_req_bcs .
 ENDTRY.
 TRY.
     CALL METHOD obj_mail->send
       EXPORTING
         i_with_error_screen = space
       RECEIVING
         result              = l_output.
   CATCH cx_send_req_bcs .
 ENDTRY.

You definitely wouldn’t have made one show yourself, but you could have included the Circulation Rundown in your activities. The Premise/Administrator groups create this rundown for us in a lot of assignments. If you arrive at your scene, make sure to check. If so, this is a good opportunity to create your most memorable Circulation Rundown and practice.

We would keep posting more crucial SAP-related items in a few articles. They may appear simple, but they are quite beneficial, and young advisors should know that.

YOU MAY LIKE THIS

Future of ABAP on Cloud

Introduction to ABAP in the Cloud

ABAP Applications for the Cloud: Modernizing for the Future

SAP

How to Email Smartform as PDF Attachment to Multiple Users?

The issue of sending Smartform yield as a PDF in an email has been raised and discussed at a number of different events. But if this need arises, we really want to reach for our old notes or use the web search engine. Recently, I received this solicitation from my company, and it wasn’t unique to me either. How Can I Send a Smartform to Several Users as a PDF Attachment?

After communicating this turn of events, I was looking for a storehouse where I could keep my code so that, should I need it in the future, I would know exactly where to look. Which warehouse for SAP Specialized is currently better than eLearningsolutions?

GPS like tool in SAP using Google Map API

Aside from the rationale of saving my scrap in the web, the other better goal was to uncover to all freshers in SAP ABAP that, you simply need to follow 4 stages for this prerequisite.

  1. Get the Smartform output in OTF (Other Text Format).
  2. Convert the OTF to Hexa decimal string format.
  3. Convert the Hexa decimal string format to Binary format.
  4. Build the email body and attach the Binary table as an attachment using CL_DOCUMENT_BCS-ADD_ATTACHMENT and send the email using CL_BCS class.

Assuming that you comprehend these four stages, you want not look the web crawler in future for such turns of events. .

Allow me to be minimal more unambiguous with the details of the four stages.

1. Smartform Output in OTF

When you call your smartform, you would get the Smart Forms OTF Table in IMPORTING parameter  JOB_OUTPUT_INFO component OTFDATA which is the structure for Smart Forms: Table OTF.

For the below snippet, the OTF data would be in w_return-otfdata.

 * Call Smartform
  CALL FUNCTION v_form_name
    EXPORTING
      control_parameters = w_ctrlop
      output_options     = w_compop
      user_settings      = abap_true
    IMPORTING
      job_output_info    = w_return " This will have all output
    EXCEPTIONS
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.
* Get Output Text Format (OTF)
  i_otf[] = w_return-otfdata[].

2. Convert the OTF to Hexa decimal string format.

The below snippet is to convert the OTF to XSTRING format.

* Import HexaString and filesize
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
      max_linewidth         = 132
    IMPORTING
      bin_filesize          = v_len_in
      bin_file              = i_xstring   " This is NOT Binary. This is Hexa
    TABLES
      otf                   = i_otf
      lines                 = i_tline
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      OTHERS                = 4.

3. Convert the Hexa decimal string format to Binary format.

* Convert Hexa String to Binary format
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = i_xstring
    TABLES
      binary_tab = i_objbin[].

Simply an idea. In the event that you can track down any capability to change over OTF straightforwardly to Twofold Organize then you can skirt the second step of switching OTF over completely to Hexa.

4. Use CL_DOCUMENT_BCS class and method ADD_ATTACHMENT to attach the document and use CL_BCS class to email the document.

If you have any desire to peruse more about CL_BCS class use, then, at that point, kindly check this valuable post ‘Send an email with title more prominent than 50 characters’.

On the off chance that you have a cutoff time, I can comprehend, you don’t need more Gyan (Sanskrit work which generally means Teaching). You are more keen on getting a functioning code which you can squeeze into your framework. Sit back and relax, I won’t dishearten you. If it’s not too much trouble, find a functioning piece which switches the Smartform over completely to PDF and messages it as a PDF connection.

*--------------------------------------------------------------------*
* Program to convert smartform as PDF and email PDF to
* multiple recipients.

*--------------------------------------------------------------------*
TABLES adr6.
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* Global Data Declaration for ease
* In actual project, please do not define all these in global
*--------------------------------------------------------------------*
DATA: i_otf       TYPE itcoo    OCCURS 0 WITH HEADER LINE,
      i_tline     LIKE tline    OCCURS 0 WITH HEADER LINE,
      i_record    LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_xstring   TYPE xstring,
* Objects to send mail.
      i_objpack   LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
      i_objtxt    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
      i_objbin    LIKE solix      OCCURS 0 WITH HEADER LINE,
      i_reclist   LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
* Work Area declarations
      wa_objhead  TYPE soli_tab,
      w_ctrlop    TYPE ssfctrlop,
      w_compop    TYPE ssfcompop,
      w_return    TYPE ssfcrescl,
      wa_buffer   TYPE string,
* Variables declarations
      v_form_name TYPE rs38l_fnam,
      v_len_in    LIKE sood-objlen.

*--------------------------------------------------------------------*
* Selection Screen
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
PARAMETERS:     p_sform TYPE tdsfname OBLIGATORY.
SELECT-OPTIONS: s_email FOR adr6-smtp_addr NO INTERVALS OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.

*--------------------------------------------------------------------*
END-OF-SELECTION.
*--------------------------------------------------------------------*
* Call your Smart
  PERFORM smartform_driver_call.

* Convert Smartform data to Hexa
  PERFORM convert_otf_to_xstring.

* Convert Hexa to Binary
  PERFORM str_to_binary.

* Send the email using cl_bcs class
  PERFORM send_multiple_user.

*--------------------------------------------------------------------*
* Sub Routines
*--------------------------------------------------------------------*
FORM smartform_driver_call .

* Call you smartform
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = p_sform
    IMPORTING
      fm_name            = v_form_name
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

* Set the control parameter
  w_ctrlop-getotf = abap_true.
  w_ctrlop-no_dialog = abap_true.
  w_compop-tdnoprev = abap_true.
  w_ctrlop-preview = space.
  w_compop-tddest = 'LOCL'.

* Call Smartform
  CALL FUNCTION v_form_name
    EXPORTING
      control_parameters = w_ctrlop
      output_options     = w_compop
      user_settings      = abap_true
    IMPORTING
      job_output_info    = w_return " This will have all output
    EXCEPTIONS
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM. " SMARTFORM_DRIVER_CALL

FORM str_to_binary .

* Convert Hexa String to Binary format
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = i_xstring
    TABLES
      binary_tab = i_objbin[].
* Sy-subrc check not required.

ENDFORM. " STR_TO_BINARY

FORM send_mail USING in_mailid.

  DATA: salutation TYPE string.
  DATA: body TYPE string.
  DATA: footer TYPE string.

  DATA: lo_send_request TYPE REF TO cl_bcs,
        lo_document     TYPE REF TO cl_document_bcs,
        lo_sender       TYPE REF TO if_sender_bcs,
        lo_recipient    TYPE REF TO if_recipient_bcs VALUE IS INITIAL,lt_message_body TYPE bcsy_text,
        lx_document_bcs TYPE REF TO cx_document_bcs,
        lv_sent_to_all  TYPE os_boolean.

  "create send request
  lo_send_request = cl_bcs=>create_persistent( ).

  "create message body and subject
  salutation ='Dear Sir/Madam,'.
  APPEND salutation TO lt_message_body.
  APPEND INITIAL LINE TO lt_message_body.

  body = 'Please find the attached the Smartform in PDF format.'.
  APPEND body TO lt_message_body.
  APPEND INITIAL LINE TO lt_message_body.

  footer = 'With Regards,'.
  APPEND footer TO lt_message_body.
  footer = 'www.softat.in.'.
  APPEND footer TO lt_message_body.
  "put your text into the document
  lo_document = cl_document_bcs=>create_document(
  i_type = 'RAW'
  i_text = lt_message_body
  i_subject = 'Smartform in PDF' ).

*DATA: l_size TYPE sood-objlen. " Size of Attachment
*l_size = l_lines * 255.
  TRY.
      lo_document->add_attachment(
      EXPORTING
      i_attachment_type = 'PDF'
      i_attachment_subject = 'Your Smartform'
      i_att_content_hex = i_objbin[] ).
    CATCH cx_document_bcs INTO lx_document_bcs.
  ENDTRY.

* Add attachment
* Pass the document to send request
  lo_send_request->set_document( lo_document ).

  "Create sender
  lo_sender = cl_sapuser_bcs=>create( sy-uname ).

  "Set sender
  lo_send_request->set_sender( lo_sender ).

  "Create recipient
  lo_recipient = cl_cam_address_bcs=>create_internet_address( in_mailid ).

*Set recipient
  lo_send_request->add_recipient(
  EXPORTING
  i_recipient = lo_recipient
  i_express = abap_true
  ).

  lo_send_request->add_recipient( lo_recipient ).

* Send email
  lo_send_request->send(
  EXPORTING
  i_with_error_screen = abap_true
  RECEIVING
  result = lv_sent_to_all ).

CONCATENATE 'Email sent to' in_mailid INTO data(lv_msg) SEPARATED BY space.
  WRITE:/ lv_msg COLOR COL_POSITIVE.
  SKIP.
* Commit Work to send the email
  COMMIT WORK.

ENDFORM.

FORM send_multiple_user.

  DATA: in_mailid TYPE ad_smtpadr.

* Begin of sending email to multiple users
* If business want email to be sent to all users at one time, it can be done

* For now we do not want to send 1 email to multiple users
* Mail has to be sent one email at a time
  LOOP AT s_email.
    CLEAR in_mailid.
    in_mailid = s_email-low.
    PERFORM send_mail USING in_mailid .
  ENDLOOP.

ENDFORM. " SEND_MULTIPLE_USER



FORM convert_otf_to_xstring .

* Get Output Text Format (OTF)
  i_otf[] = w_return-otfdata[].

* Import Binary file and filesize
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
      max_linewidth         = 132
    IMPORTING
      bin_filesize          = v_len_in
      bin_file              = i_xstring   " This is NOT Binary. This is Hexa
    TABLES
      otf                   = i_otf
      lines                 = i_tline
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      OTHERS                = 4.
* Sy-subrc check not checked

ENDFORM.

For our test, we made a straightforward smartform with simply a logo and one text line.

Stir things up around town symbol to test the smartform remain solitary.

You would see the capability module connected to this smartform. Stir things up around town symbol once more. Presently you see the boundaries of the capability, hit test symbol once more.

This is our smartform yield.

Presently, our program ought to connect this smartform yield as PDF and email it to different clients.

We should execute our program. Give the smartform name and the email ids. For the test, we are sending just to two clients. You could enter as numerous clients you need.

Execute and you would receive this message (assuming that you are trying our program).

Go to t-code SOST to check whether email truly went out. Indeed!! Indeed it did.

Allow us to browse what this email has for us.

Cool, we have the email body and an association.

Permit us to check accepting that the association is the comparable smartform we truly see above in stay lone mode.

Bingo!! It is in deed the smartform in the PDF design.

YOU MAY LIKE THIS

Introduction to SAP ABAP for HANA

Bridging the Gap: Integrating ABAP with Other Cloud Services

ABAP ON CLOUD

× How can I help you?