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

Sales Order number update in the standard logs for FSCM Credit Checks

$
0
0

This document explains how to update the Sales Order number to the logs created for FSCM credit management credit checks during SO Creation.

 

Requirement:

As a part of FSCM Credit Management, Logs will be registered in the database for the credit checking steps performed. These logs should be created for failed credit checks triggered for business partner and the sales order number should be added to these logs.

 

Prerequisites:

  1. FSCM Credit Management setup should be in place
  2. Credit Checking steps should be implemented
  3. Business Partner should be assigned to the Check Rule defined for credit checks to trigger during the SO creation under Credit Profile tab of transaction UKM_BP.

 

Functionality:

At the time of creation of Sales Order, basis the FSCM Credit Management setup and credit checking steps configurations, logs will be created for credit checks performed. (We can perform any number of credit checks based on the requirement).

Credit checks are displayed in the popup with the details of failed checks.

Sales Order will not be generated at this point of time, but logs will be posted to database. Once we continue, then only Sales Order will be created.

 

These logs can be viewed though transaction code “UKM_LOGS_DISPLAY”.

 

Challenge:

Since the Credit checking process is the intermediate step, it is not possible for the user to find the Sales Order for which credit checks are failed.

 

Solution:

For this we have implemented one implicit enhancements and one user exit to enhance the standard functionality.

  1. Implicit Enhancement in the method CHECK_ACCOUNT of class “CL_UKM_CREDIT_CHECKER”.

Pseudo Code:

DATA: lv_mem_id TYPE string.

 

                CONCATENATE is_item-partner      "Business Partner

                                                is_item-credit_sgmnt "Credit Segment

                                                is_item-iguid        "GUID

                                                l_log_handle         "Log Handle

                                                INTO lv_mem_id SEPARATED BY ','.

                EXPORT lv_mem_id = lv_mem_id TO MEMORY ID 'ZLOGID'.

  1. Implement User Exit “USEREXIT_SAVE_DOCUMENT” of Include MV45AFZZ with below Pseudo code.

 

DATA: lv_mem_id      TYPE string,

            lv_dummy       TYPE string,

            lv_partner     TYPE bu_partner,

            lv_credit_sgmt TYPE ukm_credit_sgmnt,

            lv_log_ref TYPE ukm_item_guid,

            lv_log_handle  TYPE balloghndl.

 

  CONSTANTS: c_va01  TYPE sytcode VALUE 'VA01',

                       c_va02  TYPE sytcode VALUE 'VA02'.

 

  IMPORT lv_mem_id FROM MEMORY ID 'ZLOGID'.

  FREE MEMORY ID 'ZLOGID'.

 

  IF ( sy-tcode = c_va01 OR sy-tcode = c_va02 ).

    IF lv_mem_id IS NOT INITIAL.

      SPLIT lv_mem_id at ','

         INTO lv_partner

                   lv_credit_sgmt

                   lv_log_ref

                   lv_log_handle.

 

      "Add SO# to the Credit Checking log

      MESSAGE S000(ukm_check) WITH 'Sales Order Number: ' VBAK-VBELN

                              INTO lv_dummy.

 

      "Update the log for partner, segment and log reference imported

      CALL METHOD cl_ukm_log_gate=>add_message_credit_check

        EXPORTING

          i_partner           = lv_partner

          i_credit_sgmnt  = lv_credit_sgmt

          i_log_reference = lv_log_ref

        CHANGING

          c_log_handle    = lv_log_handle.

 

      "Save the Logs

cl_ukm_log_gate=>save_logs( ).

 

    ENDIF. "IF lv_mem_id IS NOT INITIAL.

  ENDIF. "IF ( sy-tcode = 'VA01' OR sy-tcode = 'VA02' )


Result:


Transaction Types

$
0
0


Introduction


Transactions are used to execute each SAP program.  The transaction code can be entered directly by the users into the command box in the toolbar , or they can be attached to the SAP Menu.

 

Purpose


This article allows gives you a basic overview of the different types of transactions that can be created .To create a transaction we use the Tcode SE93. When we goto Tcode SE93 and try to create a Tcode, you will find that 5 types of transactions are available from which you can select th eone appropraite for your particular program. The 5 types of transactions are :

  • Dialog Transactions
  • Report Transactions
  • Object Oriented Transation
  • Parameter Transation
  • Variant Transaction

 

 

Dialog Transaction


Introduction

Dialog Transactions are used to execute programs with type ‘Dialog Module’ or ‘Module Pool’. Programs created with this type cannot be executed without creating a Tcode for it.

 

Steps

To create a Dialog Transation:-

  1. Take SE93 and click Create.
  2. Give the Tcode name to be created and a description adn click Enter.
  3. In the dialog box that pops up, select Dialog transaction.
  4. Now in the screen that appears, enter  the Program name and fill the main screen no . ( The screen whose PBO is to be executed first ).
  5. Now select the check box to Inherit GUI Attributes. Save and Check.
  6. Execute the Tcode .

 

 

Report Transation


Introduction

Report Transactions are used to create TCodes for  programs of type 1 or Executable programs.

 

Eg. Purpose

Let us say, we have created a Type 1 program for displaying the details of selected materials. Suppose our program name is ZMMRDSP001. We will now see the steps required to create a T code for the program. We will set the T Code as ZMMR001. The following are the steps needed to create it.

 

Steps

To create a report transaction:-

  1. Take SE93 and click Create.
  2. Give the T code name as ZMMR001 and a description as Material Display, and click Enter.
  3. In the dialog box that pops up, select Report transaction.
  4. Now in the screen that appears, enter  the Program name ZMMRDSP001.
  5. If you want any specific variant to be executed by default, give the variant name.
  6. Now select the check box to Inherit GUI Attributes. Save and Check.
  7. Execute the T code .

 

 

Object Oriented Transaction


Introduction

Object Oriented Transactions can be used when you want to execute a class method directly.

 

Steps

To create a Object Oriented Transaction:-

  1. Take SE93 and click Create.
  2. Give the T code name to be created and a description adn click Enter.
  3. In the dialog box that pops up, select  Object oriented transaction.
  4. Now in the screen that appears, enter  the Class Name and give the name of the method that is to be executed first.
  5. Now select the check box to Inherit GUI Attributes. Save and Check.
  6. Execute the T code .

 

 

Parameter Transaction


Introduction

Parameter Transactions are useful when you need to personalize Standard Transactions with some pre-defined values. It involves executing transactions with pre-defined values. It also provides the option of skipping the first screen ( or executing the first screen with your pre-defined values).

 

Eg. Purpose

We are going to create a transaction code ZMN which allows the user to maintain entries in the table ZMINE which has a table maintenance view. So when the user enters the transaction ZMN, he can directly see the table entries screen.

 

Steps

  1. Goto T code SE93.
  2. Enter  the Transaction Code  ZMN and give a valid description.                                                                    
  3. Choose Parameter Transaction Radio Button and Continue.
  4. Enter details in the subsequent screen as shown to the right and click Enter.
  5. Now in the bottom part you can see a section ‘Default Values’. In here, using F4 help , you can see teh fields(screen field names) available on that particular screen( SM30 in this case). Select screen field ‘VIEWNAME’ and ‘UPDATE’ now.
  6. In the right side ( Value ) add ‘ZMINE’ ( your view name which has a table maintenance view) against VIEWNAME and ‘X’ against UPDATE. [FYI:   Update is a button present in the SM30 screen which is clicked to maintain data. Setting that value to ‘X’ will give the effect of clicking the Maintain button on SM30 with viewname as ZMINE.                                                                                            
  7. Now Save and Check.And Execute. If there are no errors, you should be able to see your maintenance screen directly.

 

Output

When the user now clicks the transaction ZMN the screen he sees will be

 

 

 

Variant Transaction


Introduction

Transaction Variants can be very useful in making design level changes in Standard Transactions. They can also be sued to set default values on screens and to set screen field properties.They can then be assigned to Standard T code itself, So that these changes get reflected for all users accessing the T code , or we can set separate T code for the same.

 

Eg. Purpose

In this document , we will create a Transaction Variant for the T Code VA01, in which we will make a variant transaction(ZVA01) of VA01 in which the initial screen ( with order type etc) need not be filled as they will be defaulted and PO number made mandatory .

 

Steps

  1. Goto T Code SHD0.
  2. Enter  the Transaction Code for which you want to create a variant. In this case, enter  Tcode VA01 and give a name for your transaction variant. Say ZVA01.                                                                                              
  3. Now click the Create button. You will be taken to the Tcode VA01.
  4. Enter values in the initial screen as you would during normal processing and click enter. 
  5. Now a new screen will pop up showing all the fieldnames and properties that can be changed.                                                                         
  6. Give the values in the pop up as given above and click ENTER to go to the next screen.
  7. Similarly, you can set any properties you need in the screen and on clicking enter , the properties tab will pop up. You can makethe desired changes there. I will set PO number to required and the Document Currency to INR. I will also hide the tabstrip for Shipping details. So the values in the pop ups will be  
  8. Note that several pop ups will show.This is because a popup for each sub screen will be displayed.
  9. Now click Exit and Save button.
  10. All the values entered and shown will get displayed in a single screen. You can make any changes necessary and then save with a description.
  11. Save all and assign each to package.
  12. Now click back and you will be taken to the initial screen in SHD0. Save.
  13. Now take T Code se93 and give a new Tcode for executing the variant and click Create.
  14. In the radio button options that appear, select variant Transaction.
  15. Now go inside, and  give T Code as VA01 and variant s ZVA01 and select cross Client Check Box.
  16. Now select the check box to Inherit GUI Attributes. Save and Check.
  17. Now execute your transaction.

 

Output

You are now directed directly to the 2nd screen after skipping the initial screen with the values you have set by default through your variant. Further , if you try saving without the PO number, it will give a message asking you to fill the PO number.


Conclusion

 

So this is how the different types of transactions are created . Make sure you assign the correct type to the transaction or your program may not work correctly. Happy Coding :D.

 


Related Content

Transaction Variants

Varient Transaction

 

 

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

$
0
0

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

Sep, 2013

Introduction

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

Introduction to SEPA process:

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

1.    SEPA_Activation_Mandate_Management

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

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

 

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

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

screen1.png

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

screen2.png                                                                                                                                                                  

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

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

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

2.  Pre Notification with payment run  :

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

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

SAP Note

Description

1679118

F110:  Custom Selection for Batch Input

1760564

F110S:  Selection Check for Customers and Vendors

1770425

F111/SEPA: Mandate rejected as invalid after change

1771071

FBCJ : Reversal possible despite cleared item

1776076

F110/F111 : BADI for SEPA Mandate usage

1780941

SEPA: Direct debit Pre-Notification

1792691

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

 

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

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

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

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

screen3.png

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

screen4.png

 

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

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

scrren61.png

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

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

3.  Creation of SEPA Mandates for payment transactions :

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

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

·       Transactions used :

Creation

FSEPA_M1

Change

FSEPA_M2

Display

FSEPA_M3,FSEPA_M4

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

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

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

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

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

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

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

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

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

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

screen6.png

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

scrren71.png

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

 

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

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

SEPA_MANDATES_API_GET

Create the Mandate for a Customer

BAPI_SEPA_MANDATE_CREATE1

Modification of Mandate details for a customer

BAPI_SEPA_MANDATE_CHANGE1

 

·       Mandate Creation:

Ø Use the BAPI BAPI_SEPA_MANDATE_CREATE1 to create the mandate .

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

screen-8.png

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

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

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

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

screen9.png

 

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

Mandate modification:

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

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

screen9.png

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

screen-10.png

  Display of Mandates :

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

screen11.png

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

screen12.png

 

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

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

Display the List of Mandates:

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

screen14.png

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

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

screen15.png

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

0         

Entered

1

Active

2

To Be Confirmed

3

Locked

4

Canceled

5

Obsolete

6

CompletedCompleted

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

screen16.png

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

screen17.png

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

Variant Maintenance Tool for ABAP Reports

$
0
0

Hello Friends ,

We some times come across situation in which we have develop a report to run in Background. As far as the normal input parameters are concerned if the input criteria involves a Date Range Select-Option, one often thinks even if i schedule a background job for this report in SM36 how to dynamically change the date fields

so that the systems takes the dates automatically.

 

So for this reason a Variant Maintenance Tool in ABAP WorkBench.

 

Just follow the below steps.

Step1.

In T-code SE38 provide your report name & select the radio button Variant.

1.JPG

Step2.

Select Change button.Here you can create new Variants for your report if you don't have one create one by pressing the create button.

2.JPG

I Already have a Variant so using it directly

3.JPG

Step3. Now select the radio button Attribute & press the Change Button.

it will process to the next Screen, This the Selection Attribute Screen

4.JPG

Step4: Select "Selection Variable " column & press F4. You will see a dialog box having two option i.e Which type of Variable do you need to select for the following input value i.e a Table variable from TVARVC table or a Dynamic Date Calculation Variable.

in my Case i have selected D - Dynamic Date Calculation Varaible.

5.JPG

Step5. Select Type of Variable as D & in the Column "Name of Variable(Input only using F4)".

6.JPG

Step6. if you want the system to run the report in background & automatically pick up the posting dates as the first day & last day of the month

select the option at the very end.

7.JPG

Step7.Here you will face with two input option that is the starting & the end month of the year marked as

(Beginning of mth-xx months, end of mth+yy months)

provide 00 in the two option or simply press ok button if you want system to take the date irrespective of any year.

8.JPG

Step8.

9.JPG

So your variant is configured to run as a background havingg posting dates automatically selected by the system as he first & last of every month irrespective of the year.

at the end try to save the variant & include it in your transport request so that its easier for BASIS Admin to create jobs for your report in PRD using specific variant,.

 

Your Suggestions are always welcome.

Best Regards.

Priyesh Shah.

Upload Files to SharePoint folders From SAP

$
0
0

Hi Friends,

 

Now-a-days we hear a lot about integrating SAP with Share Point.

I have recently work on such a requirement, where in I need to Upload files to SharePoint folders from SAP. So wanted to share my experience.

 

There are two different scenarios:

 

1) SharePoint and SAP are hosted on same server.

 

2) SharePoint and SAP are hosted on different server.

 

 

1) SharePoint and SAP are hosted on same server.

 

In this scenario,

 

Files can be directly uploaded Via GUI_UPLOAD or any equivalent FM or Classes.

 

STEPS:

  • Create new document library in your share point site.
  • GOTO--> Library and click on "Open with explorer" icon as shown below

folder.JPG

  • Then the server location opens as below

path.JPG

  • Pass the path to GUI_UPLOAD to upload to the folder.

 

 

2) SharePoint and SAP are hosted on different server.

 

In this case, we make use of a facility provided by Share Point known as "Communication Through Incoming email setings" to upload files onto it's folders.

 

STEPS:

 

                                                     

  • Create new document library in your share point site.

 

  • Once library created. Go to "Document library settings". -> Communication -> Incoming email settings

 

email.JPG

 

  • Enable the settings

 

              "Incoming email"=Yes

 

              Email address = "Define unique email ID"

 

              E-Mail Attachments=Save all attachments in root folder

 

address.JPG

 

  • Use email ID, in your ABAP program to send document in email.

 

 

 

Once you send mail to specific email ID as maintained in share point site, you will see document getting placed automatically in share point whatever you send it through email (as attachment ).

Debugging Techniques in SAP CRM Web UI.

$
0
0

Hi Folks,

 

As we already know ABAP Debug tool is the most efficient toll for all our ABAP programmers . Here I would like to share few things about debugging what I know and which are going to be useful while debugging. By using below techniques we can debug more efficiently the source code.Please find the below points.

 

 

1) How to Debug from CRM to ECC?

 

We already know by doing many ways we can trigger debug mode in SAP system , like by selecting BP in application tool bar or by entering /h or /hs in command tool bar or by entering keyword with our user name break idadmin.But if we want to trigger from CRM server to ECC server or vicee versa we have to follow below method.

 

As both system different the only one way to connect is RFC user with this user name name only different SAP system's will communicate.So first of all we have to identify RFC user name in ECC and then we have to change in debugger user name with RFC user name.Please find the below screen shots for more details.

 

Settings.GIF

we can collect RFC user name from transaction code SM59 and then we have to replace that user name in USER parameter.

 

debugging.GIF

 

Note : After debugging we have to replace our user name other wise from ECC side with our user name BP won't trigger .

 

 

2) How to debug form SAP CRM Web UI in different ways?

 

A) Consider a situation we have logged on Web UI with end user credentials but that particular person doesn't have SAP GUI credentials by that time if we want to debug then we have to change name in the following path Utilities->Settings->ABAP Editor -> ABAP Debugging -> User .Please find the above screen shot for details

 

B) If we want to debug from  Web UI then we have to keep Secession Break Point and this is going to be validate for next 2 hours and we can keep maximum 32 secession break points .

 

 

 

 

Secession BP.GIF

 

 

 

 

 

3) How to reprocess the same code in debugging mode ?

 

Consider we are in debugging mode and we have run one condition but we want to run same condition again with out executing the total transaction code.For this we have keep our cursor in the line where exactly we want to run the same code again and need to select Debugger tab in menu bar then have to press go to statement  or else we have to press SHIFT+F12 short cut key .

 

Line Number 18.GIF

we have to keep our cursor from where exactly we want to run the code again and need to click on Go to statement.

 

Goto Statement.GIF

 

then we can re debug the code one more time .

 

4) To Identify Flow stack and to know Global Variable's Memory.

 

A)To Identify the the Below :- When we are debugging in CRM , we have to know flow or Screen Stack of debugging ,that means after current executing method/FM which FM/method is going to triggered to next or which FM/Method trigger earlier . This total flow is available at New Debugger tool in DESKTOP2 .Please find the attached screen shot for more details.

Screen Stack.GIF

 

 

B) To Know Global Variable Memory Details.

 

Consider we are creating a SalesOrder In ECC and we want to validate to order details before saving data in master tables .By that time we have to Global tab in SAP NEW ABAP Debug tool.Generally the names of internal tables will like this CVBAP,CVBAK.

 

Please guide me with your suggestions.....

 

 

Thanks & Regards,

Siva Krishna Boddapati

Creation of Custom Kernel BADI and Calling it in a Custom Program

$
0
0

The BADI(Business Add-in's) is an object-oriented enhancement option. The BADI defines an interface that can be implemented by BADI-implementations that are transport objects of their own. The new BADI or Kernel BADI is fully integrated into the Enhancement Framework. Within the Enhancement Framework a BADI is an enhancement option or an anchor point for an object plug-in.

 

Kernel BAdI's Features

  • Are integrated directly in the ABAP Language/Runtime
  • Improved filter support allows non-character filter types and complex filter conditions
  • Enable reusable implementation instances (Stateful BAdI)
  • Control of the lifetime of implementations (BAdI-context)
  • Allow for inheritance of implementations
  • Can be switched by the Switch Framework

 

In this document, I have demonstrated the various steps for creating a Kernel BADI and calling it in our own Custom program.

 

1. First  create a  Enhancement spot from SE18. Kernel Badi's belong to an enhancement spot.

Enhancement spots carry information about the positions at which enhancement options were created. One enhancement spot can manage several enhancement options of a Repository object. Conversely, several enhancement spots can be assigned to one enhancement option.

 

 

Enter the description and if you want you can assign the new enhancement spot to a composite enhancement spot. Composite enhancement spots are used for the semantic grouping of simple enhancement spots. A composite enhancement spot contains either one or more simple enhancement spots and/or one or more composite enhancement spots of the relevant type. You can use composite enhancement spots to combine simple enhancement spots into meaningful units.

 

 

2. On creating the Enhancement spot, you will be directed to Enhancement Spot Editor. Now we need to create a new BADI Definition.

 

 

 

3. Click on the create BADI button.

 

 

4. You will find certain options for the BADI definitions as below.

 

 


Usability - Multiple use - that is, there can be several active implementations

Limited Filter Use – This makes the BADI Filter-dependent - that is, you apply a filter value to each method called (for example, a country). A different (active) implementation is then called for each value. Possible filter values are characterized by the filter type.



Instance Generation Mode - This property controls the instantiation of the object plug-ins during execution of the statement GET BADI.

The first two specifications define context-free BAdIs.

Newly Created Instantiation - New object plug-ins are created at each execution of the statement GET BADI.

Reusing Instantiation - An object plug-in that was used once in the current internal mode is reused, if it is required more than once.

Context-Dependent Instantiation - A context must be specified for GET BADI. This context controls the instantiation. Only one object plug-in is created for each context and implementing class. Each time there is another GET BADI with the same context, it is reused. A context is an instance of a class that implements the tag interface if_badi_context. The specification takes place in the form of a reference to such an instance.



Fallback Class - Fallback class for a BADI is used if there is no active BADI implementation. This means: The GET BADI command returns a handle to an instance of the fallback class and the respective CALL BADI calls the methods of the fallback class instance. As soon as there is an active BADI implementation, the fallback class is not used any longer at runtime.


 

 

5. Now we need to add an interface to the BADI. Expand the Node of BADI definition name and double click on node Interface. You can either add existing interface or will be prompted to create.

 


 

6. On clicking ‘Yes’, you will be navigated to the below screen, where you can add a method to the new interface.


Save, activate and comeback to the BADI definition screen and activate the Enhancement Spot.

 

 

7. Next we need to implement the Enhancement spot and BADI. Right click on the BADI definition and select Create BADI Implementation.

 

 

8. First the system will ask for enhancement implementation name. Please enter a name and description.

 

 

9. Next it will ask for BADI Implementation name and Class name for implementing BADI. Enter the names and click ok.

 

 

10. Next we have to implement the interface method. Expand the BADI Definition name and double click on BADI implementation.

 

 

11. You will be directed to the enhancement implementation screen, shown below. Double click on the Interface method and you will be prompted to create implementation for the method.


 

12. On clicking yes, you will be navigated to editor for the method. Add the following code for showing a message or anything as per your requirement. Save it and activate.

 

 

So the BADI definition and implementation part is complete.

 

Next we will see how we can call this Kernel BADI in our Custom program.

 

13. Create or open an existing program in SE38. Point to the line where you need to add enhancement option. Right click and select Create Option.

 

 

14. Give an Enhancement point or section name and Enhancement spot implementation name. Here I have opted an Enhancement point and have entered Enhancement spot implementation name as ‘ZENH_IMP_TEST’ (which we have created before).

 

 

A new line will be added to the existing code as shown below.


 

15. Then add the below code which is shown in the red box below.

 

 

Apart from Classic BADI’s which are been called by Proxy class cl_exithandler, Kernel BADI’s are called directly with the reference to the BADI definition via GET BADI and CALL BADI statements.  That is one of the reasons why Kernel BADI is faster than classic BADI. Also in Classic BADI, while we call it via cl_exithandler,  we use the reference to the interface rather than BADI definition

 

16. Now activate the program and execute it. When the cursor reaches the enhancement point, where the BADI is called it will trigger all the active implementations of that BADI. Here we have only one implementation and that will be triggered, which shows the below message as we have written in the BADI implementation.

 

 

If the program fails to trigger the BADI implementation, please recheck whether everything associated with it is ‘Activated’ after the creation.

 

Thank You.

Send multiple PDF Files in a single Email uploaded from Application Server

$
0
0


This Program accepts two Input Parameters :

1) Application Server Folder path

2) Customer number

 

It fetches Email Id of the given customer; also fetches the PDF files from the given Folder; attaches all the files in a single mail and sends.

 

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

*& Report  YS_MUL_INV_MAIL1                                         *

*&                                                                     *

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

*&                                                                     *

*&                                                                     *

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

 

REPORT  ys_mul_inv_mail1 .

 

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

TYPE-POOLS: sx.

 

DATA: w_path_name          TYPE pfeflnamel,

      w_path_tmp           TYPE pfeflnamel,

      w_path               TYPE string,

      t_file_tbl           TYPE TABLE OF zsalfldir,

      w_file_tbl           TYPE zsalfldir.

 

 

DATA:

t_message_body  TYPE bcsy_text ,

g_objcont       TYPE solix_tab,

w_record        TYPE string,

 

w_pdf_xstring   TYPE xstring,

wo_send_request TYPE REF TO cl_bcs ,

wo_document     TYPE REF TO cl_document_bcs,

wo_sender       TYPE REF TO if_sender_bcs  ,

wo_recipient    TYPE REF TO if_recipient_bcs ,

wx_document_bcs TYPE REF TO cx_document_bcs ,

 

w_send          TYPE ad_smtpadr,

w_sent_to_all   TYPE os_boolean,

w_subject(50)   TYPE c,

w_adrnr         TYPE kna1-adrnr,

w_name1         TYPE kna1-name1,

w_name(40)      TYPE c,

w_subj          TYPE string, "so_obj_des,

w_invoice       TYPE vbeln_vf,

w_msg           TYPE string.

 

DATA: BEGIN OF t_file OCCURS 0,

            data(50000) TYPE c,

      END OF t_file.

 

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

*                 Selection-Screen: Parameter Declaration              *

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

 

PARAMETERS: p_kunnr TYPE kunnr OBLIGATORY,           “Customer number

      p_path TYPE rfpdo-rfbifile OBLIGATORY.  "App Serv Path

 

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

 

CLASS cl_bcs DEFINITION LOAD.

 

CLEAR: w_path_name, t_file_tbl, w_path_tmp.

REFRESH: t_file_tbl.

 

w_path_name = p_path.

 

TRANSLATE w_path_name TO LOWER CASE.

 

CALL FUNCTION 'ZRZL_READ_DIR_LOCAL'

  EXPORTING

    name           = w_path_name

  TABLES

    file_tbl       = t_file_tbl

  EXCEPTIONS

    argument_error = 1

    not_found      = 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.

ELSE.

  IF t_file_tbl[] IS INITIAL.

* Files not found

    WRITE 'Files not found.'.                               "text-001.

  ENDIF.

ENDIF.

 

CLEAR:

      t_message_body,

      w_subj,

      w_msg,

      w_invoice,

      w_adrnr,

      w_name1,

      w_send,

      w_pdf_xstring,

      g_objcont,

      w_subject.

 

 

*  Create send request

wo_send_request = cl_bcs=>create_persistent( ).

 

* Fetch Name of the Customer

SELECT SINGLE name1 INTO w_name1

   FROM kna1

  WHERE kunnr = p_kunnr.

 

CONCATENATE w_name1 ',' INTO w_name.

 

* Fetch Address number

SELECT SINGLE adrnr INTO w_adrnr

   FROM kna1

  WHERE kunnr = p_kunnr.

IF sy-subrc EQ 0.

* Fetch email address

  SELECT SINGLE smtp_addr INTO w_send

    FROM adr6

    WHERE addrnumber = w_adrnr.

  IF sy-subrc NE 0.

    MESSAGE 'Email id is not updated in customer master. ' TYPE 'E'.

  ENDIF.

ENDIF.      "kna1 sy-subrc

 

CLEAR:

  w_msg.

 

CONCATENATE 'Please find the attached INVOICE ' '.' INTO w_msg SEPARATED BY space.

 

* Create message body and name of the attachment

APPEND w_name       TO t_message_body.

APPEND INITIAL LINE TO t_message_body.

APPEND w_msg        TO t_message_body.

APPEND INITIAL LINE TO t_message_body.

APPEND 'Thank You!' TO t_message_body.

 

 

CONCATENATE ' Customer: ' p_kunnr INTO w_subj SEPARATED BY space.

 

 

* Email Body

wo_document = cl_document_bcs=>create_document(

                              i_type = 'RAW'

                              i_text = t_message_body

                              i_subject = ' ' ).

 

LOOP AT t_file_tbl INTO w_file_tbl WHERE zname_len CS 'PDF'.

 

*  CONCATENATE 'Invoice_' w_file_tbl-zname_len INTO w_subject.

  w_subject = w_file_tbl-zname_len.

  CLEAR w_path_tmp.

  CLEAR g_objcont.

 

  CONCATENATE  w_path_name '\' w_file_tbl-zname_len

  INTO w_path_tmp.

 

  OPEN DATASET w_path_tmp FOR INPUT IN BINARY MODE.

  IF sy-subrc = 0.

    DO.

      CLEAR w_path.

      READ DATASET w_path_tmp INTO w_path.

      IF sy-subrc NE 0.

        EXIT.

      ELSE.

* Append all the Index files' Data in one Internal Table

        APPEND w_path TO t_file.

        CLEAR w_path.

      ENDIF.

    ENDDO.

 

    LOOP AT t_file.

      IF t_file-data IS NOT INITIAL.

        CLEAR w_record.

        w_record = t_file-data.

        CONDENSE w_record.

      ENDIF.

    ENDLOOP.

 

    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

    EXPORTING

      text           = w_record

    IMPORTING

      buffer         = w_pdf_xstring

   EXCEPTIONS

     failed         = 1

     OTHERS         = 2 .

 

* XSTRING format is then converted to Binary Format (SOLIX_TAB) to use in the attachment mail

    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

      EXPORTING

        buffer     = w_pdf_xstring

      TABLES

        binary_tab = g_objcont.

 

 

* Add attachment

    TRY.

        CALL METHOD wo_document->add_attachment

          EXPORTING

            i_attachment_type    = 'PDF'

            i_attachment_subject = w_subject

            i_att_content_hex    = g_objcont.

 

      CATCH cx_document_bcs INTO wx_document_bcs.

 

    ENDTRY.

 

    CLOSE DATASET w_path_tmp.

  ENDIF.

 

ENDLOOP.

 

* Pass the document to send request

CALL METHOD wo_send_request->set_document( wo_document ).

 

* Email Subject (More than 50 characters)

CALL METHOD wo_send_request->set_message_subject

  EXPORTING

    ip_subject = w_subj.

 

* Create Sender

wo_sender = cl_cam_address_bcs=>create_internet_address( 'email@company.com' ). " Sender Email Id

 

* Add sender to send request

CALL METHOD wo_send_request->set_sender

  EXPORTING

    i_sender = wo_sender.

 

* Create recipient

wo_recipient = cl_cam_address_bcs=>create_internet_address( w_send ).

 

*Set recipient

CALL METHOD wo_send_request->add_recipient

  EXPORTING

    i_recipient = wo_recipient

    i_express   = 'X'.

 

* Set send immediately

wo_send_request->set_send_immediately( 'X' ).

 

* Send email

wo_send_request->send(

EXPORTING

i_with_error_screen = 'X'

RECEIVING

result = w_sent_to_all ).

 

IF sy-subrc EQ space AND w_sent_to_all EQ 'X'.

  MESSAGE 'Mail sent successfully.' TYPE 'S'.

  COMMIT WORK.

ELSE.

  MESSAGE 'Error sending Email' TYPE 'E'.

  ROLLBACK WORK.

ENDIF.

 

Hope this Program will be helpful.


How to Print Barcodes that are not supported by SAP using Smartforms

$
0
0

Introduction:

 

In this document we will work on printing a Data Matrix barcode (DMC) which is a 2D barcode not supported by SAP.

 

A 2D (two-dimensional) barcode is a graphical image that stores information both horizontally -- as one-dimensional bar codes do -- and vertically. As a result of that construction, 2D codes can store up to 7,089 characters and possibly more.

 

Below are some of the types of 2D barcodes

 

Capture.PNG

Requirement:

 

Print Data Matrix barcode (2D barcode) on zebra printers using Smartform.

 

* Similar approach can be followed for printing other 2D barcodes and the generic barcodes with specific height and width.

 

Issue:

 

SAP by default only supports PDF417 as 2D barcode and does not support Data Matrix and other 2D barcodes

 

Solution:

 

Printing other 2D barcodes which are not supported by SAP is possible by following the below steps

 

  • Printer should support the required barcode:We can check this online based on the printer model and make. Most probably you will find this information on the manufacturer’s website.

    

  • Choose an appropriate device type for the printer:Selection of device type is based on the printer you are using.  In this example we are using ZEBRA printer so the device type selction will be based on Zebra printer.This topic is dealt in more detail in the other document named ‘Working with Zebra Printers using Smartforms in SAP’ please refer to the same for additional documentation on selecting the device type for Zebra printers.  For Zebra printers we have the following device types LZEB* (* => 2/3/4) series or YZB# (# => 200/300/400) series based on the DPI resolution of the printer.

        For the demonstration as an example we will use LZEB2 device type from here on in this document.

  • Create a system barcode of type UNDEF in SAP:For creating a system barcode go to transaction SE73.

          This will take you to the SAP script Font Maintenance: Initial screen

        Capture.PNG

          Select System barcodes check box and click the change button. This will display a list of all the Barcodes on the SAP system.

 

          Click the Create button (Paper icon) at the top of the screen

          Capture.PNG

          The Choose Bar Code Technology select box will now be displayed.

          Capture.PNG

          The barcode we are adding is a new barcode symbology which is not supported by SAP, and the new barcode techcnology allows only specif types

          of barcodes symbologies to be created therefore we are going to use Old technology to create our new barcode as an undefined symbology.

 

          So Click on Old.

 

          The Create/Change System Bar Code settings screen will be displayed. For barcode type enter ‘UNDEF’ ( barcode not defined) as the data matrix

          barcode type is not defined in SAP. Also specify the height and width of the barcode.

 

          Capture.PNG

          Then save the changes by clicking on the Ok button. Now the system barcode ZDMC is created.

 

  • Create a printer barcode for the newly created system barcode with appropriate print control:

 

       For creating a system barcode go to transaction SE73. This will take you to the SAP script Font Maintenance: Initial screen

       Capture.PNG

          Select printer barcodes check box and click the change button. This will display a list of device Types available in SAP system.

 

       Capture.PNG

          In this case I am using device type LZEB2 so I will create a printer barcode for this device type. It is advisable to copy this device type to a new

             device type and then make changes to the new Z device type and use it for printing but for demonstration I am using the same device type.

 

             Double click on the device type to list the barcodes supported by this device type.

              Capture.PNG

               Notice the Prefix and Suffix value ranges used for the barcodes. Here in this case the highest number used for prefix is SBP20 and is different

               for each barcode however the suffix is same for all the barcodes. These prefix and suffix are the print controls of the barcodes supported by

               the printer.

 

               Now select the create button on the top of the screen to add a new printer barcode. This will take you to the barcode selection screen.

               Capture.PNG

               Select the system barcode you created earlier and enter the other values as shown in the screenshot above. For prefix we are entering SBP21

               because all the numbers from 1 -20 (SBP01 to SBP20) are already used so we are using the next available number SBP21 and the suffix number

               stays the same. We can use any number from 21-99 for prefix.

 

               Now the barcode is created for the device type (see screen shot  below)

               Capture.PNG

               But the print control SBP21 is empty. For the barcode to work properly we have to add commands in the print control in ZPL-II language

               (printer language).

 

               Please find the online document named 'ZPL2 command book' . The site link for the same is

               http://www.zebra.com/id/zebra/na/en/documentlibrary/manuals/en/zpl_ii_programming2.File.tmp/45541L-002_RA.pdf

 

               It is adviced to have the document before we proceed further. This command book has all the commands for printing different types of

               barcodes on a printer ( only if the printer supports it )using the ZPL2 command Lanugage.

 

               Here we are adding the Data matrix barcode, and the printer command format for printing the data matrix is: ^BXo,h,s,c,r,f,g

 

               Command Parameters:

               O – Orientation

               H – Height

               S – Quality level

               C – Columns to encode

               R – Rows to encode

               F – Format ID

               G – Escape sequence control character

 

               Refer to the attached command book for accepted and default values for the above parameters and how to use the command.

 

           Below is an example of the post script language commands used for printing a DMC barcode on the printer.

           Capture.PNG

            The printer command mainly needs to have 3 types of information

  1.      Command to indicate the type of barcode to be printed ( Marked by ^BX in the command above)
  2.        Command to indicator the start of data ( Marked by ^FD)
  3.        Command to indicator the end of data (Marked by ^FS)

 

           When working with Smartforms the prefix print control in the printer barcodes screen should have both the commands for the type of barcode

               and the command for the start of datawhereas the suffix will only have the command to mark the end of data.

 

           Capture.PNG

          Taking the above points into consideration we will have ^BXN,2,200,20,20,6,~,1^FDcommand in prefix and ^FS in suffix.  As the suffix is

             used to mark the end of data it is same for all the barcodes and hence maintained as default.

 

             Meanings of the command Parameters for prefix ^BXN,2,200,20,20,6,~,1^FD are:

              ^BX        The Data Matrix command

              N            The orientation is normal

              2              Dimensional height in dots of the individual symbol elements

              200         Quality ECC level (ECC 200)

              20           Columns to encode

              20           Rows to encode

              6              Data to be used (6 means full 256 ISO 8-bit data is used)

              ~             Escape sequence for control characters

              1              Square aspect ratio, if you required rectangle this will be 2

              ^FD        This is to mark the start of the field data to be encoded in the barcode

 

            Add the following command in the print control prefix:  ^BXN,2,200,20,20,6,~,1^FD

 

            Go to SE73 -> Select printer barcodes -> Change ->Select device type (in this case LZEB2) -> double click to display the list of barcodes supported

            by the device type.

          Capture.PNG

              Select the new print control SBP21 (barcode prefix) and click on Maintain Print control button. Following popup will be displayed.

          Capture.PNG

              Enter the command in the control characters sequence field and make sure the Hexadecimal switch is turned OFF. Then press enter.

              The print control is saved.

 

               The barcode suffix SBS00, which is default for all the barcodes holds the end of data command (see below)

           Capture.PNG

               The configuration of the printer barcode is complete. Now we can use this barcode to print the Data Matrix barcode (2D barcode) from SAP.

 

               Note:

               There can be various combinations to the prefix command. If the barcode is not printed then you have to try changing the values for the height,

               rows and columns variables in the command. The prefix combination that worked for me is: ^BXN,3,200,,,6,~,1^FD

 

               Capture.PNG

  • Use the barcode in the Smartform using a style:

 

       Please refer to online documentation for adding a barcode to a style in Smartform.

 

       After you have added the barcodes to one of the character formats of the style which is being used in the Smartform, we just have to use the

         newly created barcode type to display the 2D content as Data Matrix Barcode.

 

       See below screenshot for an example.

       Capture.PNG

       As the example depicts, use a separate text node for the 2D barcode , keep all the 2D content in a variable or write it all down in the text node.

         Select the whole text and select the character format for the DMC barcode.

        

          At this point if you try to print the barcode it is expected to see the barcode on the printout, but you might not see the barcode printed on the

         printer, the reason as i understood is that based on the ZPL2 command the data should be marked with the start of data command and End of data

         command along with the type of barcode we are trying to print. so the commands should be inserted before and after the text node that holds

          the 2D data content. This will give the printer a command saying that the data between this is to be printed as the barcode symbology specified in

          the command, in our case Data Matrix.

 

          Note : Preview will not show the barcode because literally this barcode is not in SAP system and will only be printed on the printer. So anything

          concerning the barcode has to be tested on the actual printer not the preview because both the preview and the actual print will be a lot

          different.

 

  • Create a command node before and after the text node that holds the 2D barcode content:

 

       See below screen shots for an example on how to create a command node.

   Capture.PNG

        Then enter the prefix print control we created in the printer control input field (see below).

    Capture.PNG

       Create one more command node under the 2d content text node and enter the enter the suffix print control in the printer control input

         field (see below)

    Capture.PNG

        Now test the print on the Zebra printer, the barcode should be printed on the zebra printer as shown in the screen shot below. Now take the

        printout and scan the barcode with any of the android apps or any barcode reader that support DMC barcode. Please note that the printout taken

        on your local printer from a scanned document wont be readable, so it is advised to test the barcode scanning from the actual printout or from the

        Scanned document on your computer.

       Capture.PNG

        After scanning, the barcode should display all the 2D content .

 

 

Alignment issues with the 2D barcode:

          After the barcode is printed you might notice alignment issues on the label. To solve the alignment issues the following approach can be used.

 

          Go to Smartstyle you have used in the Smartform, select the respective paragraph format node you have assigned for the barcode. Here try

          changing the alignment and spacing values (see screen shot below) and try giving it a few trials. You will be able to align barcodes after a few

          combinations.

 

          Capture.PNG

 

               Note:

               Please make sure you have enough space for the barcode when designing the layout. I mean if you are planning to have a barcode of size

               1 CM * 1 CM then make use you have a separate window on the layout with space more than the barcode size.

 

 

                                                 ----------------  THE END  -----------------

Please note that the document is based on my personal experience and the online documentation i came across. So if there is any scope of improvements in this document you are most welcome to add your comments.

 

 

 

     

 

    

Displayed the Mathematical Operations output in boxes using PIPELINE and ULINE .

$
0
0

ENTER THE T-CODE --> SE38  ,

 

 

ENTER THE PROGRAM NAME AS YOUR WISH ,

 

 

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

*& Report  Z_ASSIGNMENT_DAY21

*&

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

*&

*&

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

 

 

REPORT Z_ASSIGNMENT_DAY21.

 

 

 

 

* Three parameters are created for the standard selection screen.

PARAMETERS: NUMBER1 TYPE p LENGTH 8 DECIMALS 3,

            NUMBER2 LIKE NUMBER1,

            NUMBER3 LIKE NUMBER1.

 

PARAMETERS DISPLAYS THE FIELDS LIKE THIS,

Screenshot1.png

 

 

* Declaration of variables types Integer.

DATA: add_int TYPE p,

      sub_int TYPE p,

      mul_int TYPE p,

      div_int TYPE p,

      rem_int TYPE p.

 

 

add_int = trunc( number1 ) + trunc( number2 ) + trunc( number3 ) .

 

 

sub_int = trunc( number1 ) + trunc( number2 ) - trunc( number3 ) .

 

 

mul_int = trunc( number1 ) * trunc( number2 ) * trunc( number3 ) .

 

 

div_int = trunc( number1 ) + trunc( number2 ) / trunc( number3 ) .

 

 

rem_int = trunc( number1 ) + trunc( number2 ) MOD trunc( number3 ) .

 

 

uline at /(75).

 

 

WRITE:/ '|',3 'ADDITION' CENTERED,15 '|','SUBTRACTION' CENTERED,32 '|','MULTIPLICATION' CENTERED,50 '|','DIVISION' CENTERED,62 '|','REMAINDER' CENTERED,75 '|'.

 

 

uline at /(75).

 

 

WRITE:/ '|',3 add_int CENTERED,15 '|', sub_int CENTERED,32 '|', mul_int CENTERED,50 '|', div_int CENTERED,62 '|', rem_int CENTERED,75 '|'.

 

 

uline at /(75).

 

 

* Declaration of variables type Packed numbers.

DATA: add_dec TYPE p LENGTH 8 DECIMALS 3,

      sub_dec LIKE add_dec,

      mul_dec LIKE add_dec,

      div_dec LIKE add_dec,

      rem_dec LIKE add_dec.

 

 

add_dec = frac( number1 ) + frac( number2 ) + frac( number3 ) .

 

 

sub_dec = frac( number1 ) + frac( number2 ) - frac( number3 ) .

 

 

mul_dec = frac( number1 ) * frac( number2 ) * frac( number3 ) .

 

 

div_dec = frac( number1 ) + frac( number2 ) / frac( number3 ) .

 

 

rem_dec = frac( number1 ) + frac( number2 ) MOD frac( number3 ) .

 

 

uline at /(75).

 

WRITE:/ '|',3 'ADDITION' CENTERED,15 '|','SUBTRACTION' CENTERED,32 '|','MULTIPLICATION' CENTERED,50 '|','DIVISION' CENTERED,62 '|','REMAINDER' CENTERED,75 '|'.

 

uline at /(75).

 

WRITE:/ '|',3 add_dec CENTERED,15 '|', sub_dec CENTERED,32 '|', mul_dec CENTERED,50 '|', div_dec CENTERED,62 '|', rem_dec CENTERED,75 '|'.

 

uline at /(75).

 

 

OUTPUT :

 

 

Screenshot2.png

 

 

Happy Coding,

Vamsi Konaki

Changing Mail Text/ Subject line for Standard Output Types in NACE Transaction

$
0
0

Hi Guys,

 

Below steps helps in understanding about Changing Mail  Text/ Subject line for Standard Output Types in NACE Transaction.

 

 

Changing the Standard Output type Mail Text/Subject Line

  1. Go to NACE Transaction
  2. Select the respective Application as selected below.

3. Then on the top you can see 'Output Types' - select it.

4. In the next screen as shown below - select the respective output type and double click on 'Mail  Title and Texts' under 'Output  Types' in left side under 'Dialog Structure'.

5. In the next screen click on 'EDIT or Change' then 'Mail title and texts' portion turns to edit mode

6. Select the respective language as screen below and then click on 'Text' [Pen/Pencil like Image] - Also if you want to change the Title i.e. Subject - it also can   be changed.

 

7.Then opens a screen where you can maintain the mail text.

8. Save it and it request for a TR# provide it and check executing your process and see if the mail text is changed.

    • By Mohammed Rafi

     

     

    Regards,

    Rafi

    SAP note 1906078 - FTW1A: BADI for additional selections from BKPF - implementation

    $
    0
    0

    This document has as purpose to help anyone facing issues implementing note 1906078 (step 3)

    Note 1906078 is a pre-requisite for note 1923322, but after step 3, you need to stop and implement note 1923322 and then come back again to your manual tasks.

     

    Step 1: The report ZFTW1A_BADI_IMPLEMENTATION is provided under 'Attachements' tab. Copy and execute this report.      

    Step 2: implement the note via snote

    Step 3: Goto transaction SE18 and enter BADI name as BADI_TXW_DATA_SELECTION_QUERY. Create BADI Implementation EXTRACT_TXW_FI_POS with Enhancement Implementation ZTXW_FI_POS, implementing class ZCL_TXW_SELECT and with Description 'Additional fields to be filled in customer include'.


    here are the screen shots

    snap1318.png


    snap1319.pngsnap1320.png

    Here I changed the name of my class as it was not getting created for some unknown reasons)

    snap1321.png


    snap1323.pngsnap1324.png

    Step 4: The document BADI_Implementation_Code gives the code to be implemented for each of the methods. Activate the methods after implementation of the note 1923322.


    You need to implement note 1923322 here.

    double click on the class ZCL... and update the private section with the codes provided in note attachment

    snap1325.png


     

    snap1327.png


    Paste the   methods in the implementation section and take note that in the second method, the first line 'method <method name> is missing.


    snap1328.png


    For step 5 and step 6, follow the instructions in the note and you will probably require an access key .


    Hope it helps.


    The look of your methods change by clicking on the following buttons:

    snap1329.pngsnap1330.png



    I would like to thankJann Willms  and andrea montella for their help when I was getting lots of problem to implement the notes:

    The following threads can also be useful.

    Re: SAP note 1906078 - FTW1A: BADI for additional selections from BKPF - implementation issue

    FTW1A: BADI for additional selections from BKPF

    ABAP code lighter for SCN.sap.com

    $
    0
    0

    Hello colleagues!

    As there is no support of ABAP programming language in syntax highlighting in SCN's WYSIWYG editor at the moment, I wrote the ABAP code lighter for scn.sap.com.

    1.png

     

    How to install

    In order to install the ABAP code lighter, just copy the source code below and paste it into your ABAP editor (SE80). Then activate it (Ctrl+F3).

     

    How to use

    1. Copy the source code of your ABAP program in the text editor at the left, then press F8.

    1.png

    2. Copy generated HTML code from the text editor at the right and paste it in your SCN post in HTML mode.

    2.png

    Below you can see the source code of the progrm and the result of its work at the same time.

    I hope you will like it!

     

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

    *& Report  Z_CODE_LIGHTER

    *&

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

    *&

    *&

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

     

    REPORT z_code_lighter.

     

    CONSTANTS:

      gc_begin         TYPE text1024 VALUE`<BODY_BEGIN>`,

      gc_end           TYPE text1024 VALUE`</BODY_END>`,

      gc_blue          TYPE text1024 VALUE`<SPAN_BLUE>`,

      gc_grey          TYPE text1024 VALUE`<SPAN_GREY>`,

      gc_green         TYPE text1024 VALUE`<SPAN_GREEN>`,

      gc_light_blue    TYPE text1024 VALUE`<SPAN_LIGHT_BLUE>`,

      gc_brown         TYPE text1024 VALUE`<SPAN_BROWN>`,

      gc_violet        TYPE text1024 VALUE`<SPAN_VIOLET>`,

      gc_span_close    TYPE text1024 VALUE`</SPAN_CLOSE>`,

      gc_italic        TYPE text1024 VALUE`<ITALIC>`,

      gc_italic_close  TYPE text1024 VALUE`</ITALIC_CLOSE>`,

      gc_dummy         TYPE text1024 VALUE`<DUMMY>`,

     

      gc_begin0        TYPE text1024 VALUE`<PRE class='jive_text_macro jive_macro_quote' jivemacro='quote' _modifiedtitle='true'>`,

      gc_end0          TYPE text1024 VALUE`</PRE>`,

      gc_blue0         TYPE text1024 VALUE`<SPAN style='color: #0000ff;'>`,

      gc_grey0         TYPE text1024 VALUE`<SPAN style='color: #808080;'>`,

      gc_green0        TYPE text1024 VALUE`<SPAN style='color: #4DA616;'>`,

      gc_light_blue0   TYPE text1024 VALUE`<SPAN style='color: #3399FF;'>`,

      gc_brown0        TYPE text1024 VALUE`<SPAN style='color: #800097;'>`,

      gc_violet0       TYPE text1024 VALUE`<SPAN style='color: #800080;'>`,

      gc_span_close0   TYPE text1024 VALUE`</SPAN>`,

      gc_italic0       TYPE text1024 VALUE`<EM>`,

      gc_italic_close0 TYPE text1024 VALUE`</EM>`.

     

    TYPE-POOLS abap.

     

    TYPES:

      BEGINOF ty_keyword,

        word TYPE text50,

      ENDOF ty_keyword.

     

    DATA:

      go_dock TYPEREFTO cl_gui_docking_container,

      go_container_1 TYPEREFTO cl_gui_container,

      go_editor_1    TYPEREFTO cl_gui_textedit,

      go_container_2 TYPEREFTO cl_gui_container,

      go_editor_2    TYPEREFTO cl_gui_textedit,

      gt_code        TYPESTANDARDTABLEOF text1024,

      gt_keywords    TYPESTANDARDTABLEOF ty_keyword,

      g_suppress     TYPE abap_bool.

     

     

    REFRESH gt_keywords.

    PERFORM words.

     

    SELECTION-SCREENBEGINOFSCREEN2000.

    SELECTION-SCREENENDOFSCREEN2000.

     

    START-OF-SELECTION.

      CALLSELECTION-SCREEN2000.

     

    ATSELECTION-SCREEN.

      REFRESH gt_code.

      CALLMETHOD go_editor_1->get_text_as_r3table

        IMPORTING

          table = gt_code.

     

      PERFORM color.

     

      FIELD-SYMBOLS<s_code>LIKELINEOF gt_code.

      LOOPAT gt_code ASSIGNING<s_code>.

        CONCATENATE`<P style='font-family:courier;color:black'>`<s_code>'</P>'INTO<s_code>.

      ENDLOOP.

     

      DATA: gt_code_tmp LIKE gt_code.

      gt_code_tmp = gt_code.

      REFRESH gt_code.

     

      APPEND gc_begin TO gt_code.

      APPENDLINESOF gt_code_tmp TO gt_code.

      APPEND gc_end TO gt_code.

     

      LOOPAT gt_code ASSIGNING<s_code>.

        REPLACEALLOCCURRENCESOF gc_begin        IN<s_code>WITH gc_begin0.

        REPLACEALLOCCURRENCESOF gc_end          IN<s_code>WITH gc_end0.

        REPLACEALLOCCURRENCESOF gc_blue         IN<s_code>WITH gc_blue0.

        REPLACEALLOCCURRENCESOF gc_grey         IN<s_code>WITH gc_grey0.

        REPLACEALLOCCURRENCESOF gc_green        IN<s_code>WITH gc_green0.

        REPLACEALLOCCURRENCESOF gc_light_blue   IN<s_code>WITH gc_light_blue0.

        REPLACEALLOCCURRENCESOF gc_brown        IN<s_code>WITH gc_brown0.

        REPLACEALLOCCURRENCESOF gc_violet       IN<s_code>WITH gc_violet0.

        REPLACEALLOCCURRENCESOF gc_span_close   IN<s_code>WITH gc_span_close0.

        REPLACEALLOCCURRENCESOF gc_italic       IN<s_code>WITH gc_italic0.

        REPLACEALLOCCURRENCESOF gc_italic_close IN<s_code>WITH gc_italic_close0.

      ENDLOOP.

     

      CALLMETHOD go_editor_2->set_text_as_r3table

        EXPORTING

          table          = gt_code

        EXCEPTIONS

          error_dp       = 1

          error_dp_create = 2

          OTHERS         = 3.

     

      CALLSELECTION-SCREEN2000.

     

    ATSELECTION-SCREENOUTPUT.

      CHECK go_dock ISNOTBOUND.

      CREATEOBJECT go_dock

        EXPORTING

          parent = cl_gui_container=>screen0

          side  = cl_gui_docking_container=>dock_at_left

          ratio = 90.

     

      DATA go_splitter TYPEREFTO cl_gui_splitter_container.

     

      CREATEOBJECT go_splitter

        EXPORTING

          parent = go_dock

          rows   = 1

          columns = 2.

     

      CHECK go_container_1 ISNOTBOUND.

      CALLMETHOD go_splitter->get_container

        EXPORTING

          row      = 1

          column   = 1

        RECEIVING

          container = go_container_1.

     

      CHECK go_editor_1 ISNOTBOUND.

     

      CREATEOBJECT go_editor_1

        EXPORTING

          parent                    = go_container_1

          wordwrap_mode             = cl_gui_textedit=>wordwrap_at_fixed_position

          wordwrap_position         = 1024

          wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

     

      CHECK go_container_2 ISNOTBOUND.

      CALLMETHOD go_splitter->get_container

        EXPORTING

          row      = 1

          column   = 2

        RECEIVING

          container = go_container_2.

     

      CHECK go_container_2 ISBOUND.

      CHECK go_editor_2 ISNOTBOUND.

     

      CREATEOBJECT go_editor_2

        EXPORTING

          parent                    = go_container_2

          wordwrap_mode             = cl_gui_textedit=>wordwrap_at_fixed_position

          wordwrap_position         = 1024

          wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

     

      IF go_editor_2 ISBOUND.

        CALLMETHOD go_editor_2->set_readonly_mode.

      ENDIF.

     

     

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

    *&      Form  color

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

    *       text

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

    FORM color.

     

      DATA:

        l_gt  TYPE text100,

        l_lt  TYPE text100,

        l_gt2 TYPE text100,

        l_lt2 TYPE text100.

     

      FIELD-SYMBOLS<s_code>LIKELINEOF gt_code.

     

     

      LOOPAT gt_code ASSIGNING<s_code>.

     

        CONCATENATE'&g''t;'INTO l_gt.

        CONCATENATE'&l''t;'INTO l_lt.

     

        REPLACEALLOCCURRENCESOF'>'IN<s_code>WITH l_gt.

        REPLACEALLOCCURRENCESOF'<'IN<s_code>WITH l_lt.

     

        CONCATENATE gc_brown l_gt gc_span_close INTO l_gt2.

        CONCATENATE gc_brown l_lt gc_span_close INTO l_lt2.

     

        REPLACEALLOCCURRENCESOF l_gt IN<s_code>WITH l_gt2.

        REPLACEALLOCCURRENCESOF l_lt IN<s_code>WITH l_lt2.

     

        IF<s_code>(1) = '*'.

    *     Comments with asterisk:

          PERFORM color_comments USING'\*.*' gc_grey gc_span_close

                              CHANGING<s_code>.

        ELSE.

    *     Key words:

          PERFORM color_key_words USING'[a-zA-Z_-]+\w' gc_blue gc_span_close

                               CHANGING<s_code>.

     

    *     Digits in brackets:

          DATA: l_open  TYPE text1024,

                l_close TYPE text1024.

          CONCATENATE'(' gc_light_blue INTO l_open.

          CONCATENATE gc_span_close ')'INTO l_close.

          PERFORM color_text USING'\((\d+)\)'"regex

                                   l_open      "open tag

                                   l_close     "close tag

                          CHANGING<s_code>.

     

          CONCATENATE gc_brown '(' gc_span_close INTO l_gt.

          CONCATENATE gc_brown ')' gc_span_close INTO l_lt.

          REPLACEALLOCCURRENCESOF'('IN<s_code>WITH l_gt.

          REPLACEALLOCCURRENCESOF')'IN<s_code>WITH l_lt.

     

    *     Detached digits (TODO):

          PERFORM color_text USING'\d\d*'"regex

                                    gc_light_blue           "open tag

                                    gc_span_close           "close tag

                           CHANGING<s_code>.

     

          CONCATENATE gc_violet ',' gc_span_close INTO l_gt.

          CONCATENATE gc_violet '.' gc_span_close INTO l_lt.

          REPLACEALLOCCURRENCESOF','IN<s_code>WITH l_gt.

          REPLACEALLOCCURRENCESOF'.'IN<s_code>WITH l_lt.

     

          CONCATENATE gc_violet `=>` gc_span_close INTO l_gt.

          REPLACEALLOCCURRENCESOF`=>`IN<s_code>WITH l_gt.

     

          CONCATENATE gc_violet `->` gc_span_close INTO l_gt.

          REPLACEALLOCCURRENCESOF`->`IN<s_code>WITH l_gt.

     

          CONCATENATE gc_violet ` = ` gc_span_close INTO l_gt.

          REPLACEALLOCCURRENCESOF` = `IN<s_code>WITH l_gt.

     

    *     Text in inverted commas:

          PERFORM color_text USING`([\'][^\']*[\'])` gc_green gc_span_close

                          CHANGING<s_code>.

     

    *     Texs in SQL-like inverted commas:

          PERFORM color_text USING'([\`][^\`]*[\`])' gc_green gc_span_close

                          CHANGING<s_code>.

     

    *     Comments with quotation marks:

          PERFORM color_comments USING'".*' gc_grey gc_span_close

                              CHANGING<s_code>.

        ENDIF.

      ENDLOOP.

     

    ENDFORM.                    "color

     

     

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

    *&      Form  color_key_words

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

    *       text

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

    *      -->U_REGEX      text

    *      -->U_OPEN_TAG   text

    *      -->U_CLOSE_TAG  text

    *      -->CS_CODE      text

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

    FORM color_key_words USING u_regex     TYPE text1024

                               u_open_tag  TYPE text1024

                               u_close_tag TYPE text1024

                      CHANGING cs_code     TYPEany.

     

      DATA:

        lt_code    LIKE gt_code,

        lo_matcher TYPEREFTO cl_abap_matcher,

        lf_success TYPE abap_bool VALUE abap_true,

        ls_match   TYPE match_result,

        l_keyword  TYPE text1024,

        l_offset   TYPE i,

        l_newtext  TYPE text1024.

     

      FIELD-SYMBOLS:

        <s_line>  LIKELINEOF lo_matcher->table,

        <s_code>  LIKELINEOF gt_code,

        <keyword>LIKELINEOF gt_keywords.

     

     

      APPEND cs_code TO lt_code.

      lo_matcher = cl_abap_matcher=>create( pattern    = u_regex

                                            ignore_case = abap_true

                                            table      = lt_code ).

      CHECK lo_matcher ISBOUND.

      WHILE lf_success = abap_true.

        lf_success = lo_matcher->find_next().

        CHECK lf_success = abap_true.

        ls_match = lo_matcher->get_match().

        CHECK ls_match ISNOTINITIAL.

        READTABLE lo_matcher->table ASSIGNING<s_line>INDEX ls_match-line.

        CHECK sy-subrc = 0.

        READTABLE gt_code ASSIGNING<s_code>INDEX ls_match-line.

        CHECK sy-subrc = 0.

        CHECK<s_line>(1)NE'*'.

        l_keyword = <s_line>+ls_match-offset(ls_match-length).

        TRANSLATE l_keyword TOUPPERCASE.

        IF g_suppress = abap_true.

          g_suppress = abap_false.

          CONTINUE.

        ENDIF.

        READTABLE gt_keywords ASSIGNING<keyword>WITHKEY word = l_keyword.

        CHECK sy-subrc = 0.

        IF<keyword> = 'FORM'.

          g_suppress = abap_true.

        ENDIF.

        l_offset = ls_match-offset - 1.

        IF l_offset GE0AND l_offset LT STRLEN(<s_line>).

          CHECK<s_line>+l_offset(1) = ` `.

        ENDIF.

        CONCATENATE u_open_tag <s_line>+ls_match-offset(ls_match-length) u_close_tag INTO l_newtext.

        lf_success = lo_matcher->replace_found( l_newtext ).

      ENDWHILE.

     

      lt_code = lo_matcher->table.

      READTABLE lt_code INTO cs_code INDEX1.

     

    ENDFORM.                    "color_key_words

     

     

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

    *&      Form  color_comments

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

    *       text

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

    *      -->U_REGEX      text

    *      -->U_OPEN_TAG   text

    *      -->U_CLOSE_TAG  text

    *      -->CS_CODE      text

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

    FORM color_comments USING u_regex     TYPE text1024

                              u_open_tag  TYPE text1024

                              u_close_tag TYPE text1024

                     CHANGING cs_code     TYPE text1024.

     

      DATA:

        l_open_tag  TYPE text1024,

        l_close_tag TYPE text1024.

     

      CONCATENATE gc_italic u_open_tag        INTO l_open_tag.

      CONCATENATE u_close_tag gc_italic_close INTO l_close_tag.

     

      PERFORM color_text USING u_regex

                               l_open_tag

                               l_close_tag

                      CHANGING cs_code.

     

    ENDFORM.                    "color_comments

     

     

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

    *&      Form  color_text

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

    *       text

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

    *      -->U_REGEX      text

    *      -->U_OPEN_TAG   text

    *      -->U_CLOSE_TAG  text

    *      -->CS_CODE      text

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

    FORM color_text USING u_regex     TYPE text1024

                          u_open_tag  TYPE text1024

                          u_close_tag TYPE text1024

                 CHANGING cs_code     TYPE text1024.

     

      TYPES:

        BEGINOF ty_res,

          textTYPE text1024,

        ENDOF ty_res.

     

      DATA:

        ls_match  TYPE match_result,

        ls_res    TYPE ty_res,

        lt_res    TYPESTANDARDTABLEOF ty_res,

        l_offset  TYPE i,

        l_length  TYPE i,

        l_newtext TYPE text1024,

        lf_change TYPE flag.

     

      DO999TIMES.

        lf_change = abap_true.

        CLEAR ls_match.

        FINDFIRSTOCCURRENCEOFREGEX u_regex IN cs_code MATCHOFFSET ls_match-offset

                                                          MATCHLENGTH ls_match-length.

        IF ls_match-length >0.

          IF u_regex = '\((\d+)\)'."Remove brackets from digits in brackets

            SUBTRACT2FROM ls_match-length.

            ADD1TO ls_match-offset.

          ELSEIF u_regex = '\d\d*'.

     

            l_offset = ls_match-offset - 1.

            IF cs_code+l_offset(1) = ` `

            OR cs_code+l_offset(1) = space

            OR cs_code+l_offset(1)ISINITIAL.

              lf_change = abap_true.

              l_offset = ls_match-offset + ls_match-length.

              IF l_offset GE0AND l_offset LT STRLEN( cs_code ).

                IF cs_code+l_offset(1) = ` `

                OR cs_code+l_offset(1) = space

                OR cs_code+l_offset(1)ISINITIAL

                OR cs_code+l_offset(1) = '.'.

                  lf_change = abap_true.

                ELSE.

                  lf_change = abap_false.

                ENDIF.

              ENDIF.

            ELSE.

              lf_change = abap_false.

            ENDIF.

          ENDIF.

     

          ls_res-text = cs_code+ls_match-offset(ls_match-length).

          REPLACEALLOCCURRENCESOFREGEX'[\<][^\>]+[\>]'IN ls_res-text WITH''."Clear text content from HTML-tags

          APPEND ls_res TO lt_res.

     

          IF lf_change = abap_false.

            l_newtext = gc_dummy.

          ELSE.

            CONCATENATE u_open_tag gc_dummy u_close_tag INTO l_newtext.

          ENDIF.

          REPLACEFIRSTOCCURRENCEOFREGEX u_regex IN cs_code WITH l_newtext.

        ELSE.

          EXIT.

        ENDIF.

      ENDDO.

     

      LOOPAT lt_res INTO ls_res.

        REPLACEFIRSTOCCURRENCEOF gc_dummy IN cs_code WITH ls_res-text.

      ENDLOOP.

     

    ENDFORM.                    "color_text

     

     

    DEFINE add_word.

      append&1 to gt_keywords.

    END-OF-DEFINITION.

     

     

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

    *&      Form  words

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

    *       text

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

    FORM words.

     

      add_word 'ABS'.

      add_word 'ACOS'.

      add_word 'ADD'.

      add_word 'ADD-CORRESPONDING'.

      add_word 'ADJACENT'.

      add_word 'AFTER'.

      add_word 'ALIASES'.

      add_word 'ALL'.

      add_word 'ANALYZER'.

      add_word 'AND'.

      add_word 'ANY'.

      add_word 'APPEND'.

      add_word 'AS'.

      add_word 'ASCENDING'.

      add_word 'ASIN'.

      add_word 'ASSIGN'.

      add_word 'ASSIGNED'.

      add_word 'ASSIGNING'.

      add_word 'AT'.

      add_word 'ATAN'.

      add_word 'AUTHORITY-CHECK'.

      add_word 'AVG'.

      add_word 'BACK'.

      add_word 'BOUND'.

      add_word 'BEFORE'.

      add_word 'BEGIN'.

      add_word 'BINARY'.

      add_word 'BIT'.

      add_word 'BIT-AND'.

      add_word 'BIT-NOT'.

      add_word 'BIT-OR'.

      add_word 'BIT-XOR'.

      add_word 'BLANK'.

      add_word 'BLOCK'.

      add_word 'BREAK'.

      add_word 'BREAK-POINT'.

      add_word 'BUFFER'.

      add_word 'BY'.

      add_word 'C'.

      add_word 'CALL'.

      add_word 'CASE'.

      add_word 'CATCH'.

      add_word 'CEIL'.

      add_word 'CENTERED'.

      add_word 'CHAIN'.

      add_word 'CHANGE'.

      add_word 'CHANGING'.

      add_word 'CHECK'.

      add_word 'CHECKBOX'.

      add_word 'CLASS'.

      add_word 'CLASS-DATA'.

      add_word 'CLASS-EVENTS'.

      add_word 'CLASS-METHODS'.

      add_word 'CLASS-POOL'.

      add_word 'CLEAR'.

      add_word 'CLIENT'.

      add_word 'CLOSE'.

      add_word 'CNT'.

      add_word 'CODE'.

      add_word 'COLLECT'.

      add_word 'COMMENT'.

      add_word 'COMMIT'.

      add_word 'COMMUNICATION'.

      add_word 'COMPUTE'.

      add_word 'CONCATENATE'.

      add_word 'CONDENSE'.

      add_word 'CONSTANTS'.

      add_word 'CONTEXT'.

      add_word 'CONTEXTS'.

      add_word 'CONTINUE'.

      add_word 'CONTROL'.

      add_word 'CONTROLS'.

      add_word 'CONVERT'.

      add_word 'COPY'.

      add_word 'CORRESPONDING'.

      add_word 'COS'.

      add_word 'COSH'.

      add_word 'COUNT'.

      add_word 'COUNTRY'.

      add_word 'CREATE'.

      add_word 'CURRENCY'.

      add_word 'CURSOR'.

      add_word 'CUSTOMER-FUNCTION'.

      add_word 'DATA'.

      add_word 'DATABASE'.

      add_word 'DATASET'.

      add_word 'DEFINITION'.

      add_word 'DEFERRED'.

      add_word 'DELETE'.

      add_word 'DECIMALS'.

      add_word 'DEFAULT'.

      add_word 'DEFINE'.

      add_word 'DELETE'.

      add_word 'DEMAND'.

      add_word 'DESCENDING'.

      add_word 'DESCRIBE'.

      add_word 'DIALOG'.

      add_word 'DISPLAY'.

      add_word 'DISTINCT'.

      add_word 'DIV'.

      add_word 'DIVIDE'.

      add_word 'DIVIDE-CORRESPONDING'.

      add_word 'DO'.

      add_word 'DUPLICATES'.

      add_word 'DYNPRO'.

      add_word 'EDIT'.

      add_word 'EDITOR-CALL'.

      add_word 'ELSE'.

      add_word 'ELSEIF'.

      add_word 'END-OF-DEFINITION'.

      add_word 'END-OF-PAGE'.

      add_word 'END-OF-SELECTION'.

      add_word 'END'.

      add_word 'ENDAT'.

      add_word 'ENDCASE'.

      add_word 'ENDCATCH'.

      add_word 'ENDCHAIN'.

      add_word 'ENDCLASS'.

      add_word 'ENDDO'.

      add_word 'ENDEXEC'.

      add_word 'ENDFORM'.

      add_word 'ENDFUNCTION'.

      add_word 'ENDIF'.

      add_word 'ENDINTERFACE'.

      add_word 'ENDLOOP'.

      add_word 'ENDMETHOD'.

      add_word 'ENDMODULE'.

      add_word 'ENDON'.

      add_word 'ENDPROVIDE'.

      add_word 'ENDSELECT'.

      add_word 'ENDWHILE'.

      add_word 'ENTRIES'.

      add_word 'EVENT'.

      add_word 'EVENTS'.

      add_word 'EXEC'.

      add_word 'EXIT'.

      add_word 'EXIT-COMMAND'.

      add_word 'EXP'.

      add_word 'EXPONENT'.

      add_word 'EXPORT'.

      add_word 'EXPORTING'.

      add_word 'EXCEPTIONS'.

      add_word 'EXTENDED'.

      add_word 'EXTRACT'.

      add_word 'FETCH'.

      add_word 'FIELD'.

      add_word 'FIELD-GROUPS'.

      add_word 'FIELD-SYMBOLS'.

      add_word 'FIELDS'.

      add_word 'FINAL'.

      add_word 'FLOOR'.

      add_word 'FOR'.

      add_word 'FORM'.

      add_word 'FORMAT'.

      add_word 'FRAC'.

      add_word 'FRAME'.

      add_word 'FREE'.

      add_word 'FROM'.

      add_word 'FUNCTION'.

      add_word 'FUNCTION-POOL'.

      add_word 'GENERATE'.

      add_word 'GET'.

      add_word 'GROUP'.

      add_word 'HANDLER'.

      add_word 'HASHED'.

      add_word 'HEADER'.

      add_word 'HELP-ID'.

      add_word 'HELP-REQUEST'.

      add_word 'HIDE'.

      add_word 'HOTSPOT'.

      add_word 'ICON'.

      add_word 'ID'.

      add_word 'IF'.

      add_word 'IMPORT'.

      add_word 'IMPORTING'.

      add_word 'IN'.

      add_word 'INCLUDE'.

      add_word 'INDEX'.

      add_word 'INFOTYPES'.

      add_word 'INITIAL'.

      add_word 'INITIALIZATION'.

      add_word 'INNER'.

      add_word 'INPUT'.

      add_word 'INSERT'.

      add_word 'INTENSIFIED'.

      add_word 'INTERFACE'.

      add_word 'INTERFACE-POOL'.

      add_word 'INTERFACES'.

      add_word 'INTO'.

      add_word 'INVERSE'.

      add_word 'IS'.

      add_word 'JOIN'.

      add_word 'KEY'.

      add_word 'LANGUAGE'.

      add_word 'LAST'.

      add_word 'LEAVE'.

      add_word 'LEFT'.

      add_word 'LEFT-JUSTIFIED'.

      add_word 'LIKE'.

      add_word 'LINAL'.

      add_word 'LINE'.

      add_word 'LINE-COUNT'.

      add_word 'LINE-SELECTION'.

      add_word 'LINE-SIZE'.

      add_word 'LINES'.

      add_word 'LIST-PROCESSING'.

      add_word 'LOAD'.

      add_word 'LOAD-OF-PROGRAM'.

      add_word 'LOCAL'.

      add_word 'LOCALE'.

      add_word 'LOG'.

      add_word 'LOG10'.

      add_word 'LOOP'.

      add_word 'M'.

      add_word 'MARGIN'.

      add_word 'MASK'.

      add_word 'MATCHCODE'.

      add_word 'MAX'.

      add_word 'MEMORY'.

      add_word 'MESSAGE'.

      add_word 'MESSAGE-ID'.

      add_word 'MESSAGES'.

      add_word 'METHOD'.

      add_word 'METHODS'.

      add_word 'MIN'.

      add_word 'MOD'.

      add_word 'MODE'.

      add_word 'MODIF'.

      add_word 'MODIFY'.

      add_word 'MODULE'.

      add_word 'MOVE'.

      add_word 'MOVE-CORRESPONDING'.

      add_word 'MULTIPLY'.

      add_word 'MULTIPLY-CORRESPONDING'.

      add_word 'NEW'.

      add_word 'NEW-LINE'.

      add_word 'NEW-PAGE'.

      add_word 'NEXT'.

      add_word 'NO'.

      add_word 'NE'.

      add_word 'NOT'.

      add_word 'NO-GAP'.

      add_word 'NO-GAPS'.

      add_word 'NO-HEADING'.

      add_word 'NO-SCROLLING'.

      add_word 'NO-SIGN'.

      add_word 'NO-TITLE'.

      add_word 'NO-ZERO'.

      add_word 'NODES'.

      add_word 'NON-UNIQUE'.

      add_word 'O'.

      add_word 'OBJECT'.

      add_word 'OBLIGATORY'.

      add_word 'OCCURS'.

      add_word 'OCCURRENCES'.

      add_word 'OF'.

      add_word 'OFF'.

      add_word 'ON'.

      add_word 'OPEN'.

      add_word 'OR'.

      add_word 'ORDER'.

      add_word 'OTHERS'.

      add_word 'OUTER'.

      add_word 'OUTPUT'.

      add_word 'OVERLAY'.

      add_word 'PACK'.

      add_word 'PAGE'.

      add_word 'PARAMETER'.

      add_word 'PARAMETERS'.

      add_word 'PERFORM'.

      add_word 'PF-STATUS'.

      add_word 'POSITION'.

      add_word 'PRINT'.

      add_word 'PRINT-CONTROL'.

      add_word 'PRIVATE'.

      add_word 'PROCESS'.

      add_word 'PROGRAM'.

      add_word 'PROPERTY'.

      add_word 'PROTECTED'.

      add_word 'PROVIDE'.

      add_word 'PUBLIC'.

      add_word 'PUT'.

      add_word 'RADIOBUTTON'.

      add_word 'RAISE'.

      add_word 'RAISING'.

      add_word 'RANGE'.

      add_word 'RANGES'.

      add_word 'READ'.

      add_word 'RECEIVE'.

      add_word 'REF'.

      add_word 'REFRESH'.

      add_word 'REJECT'.

      add_word 'REPLACE'.

      add_word 'REPORT'.

      add_word 'REQUESTED'.

      add_word 'RESERVE'.

      add_word 'RESET'.

      add_word 'RIGHT-JUSTIFIED'.

      add_word 'ROLLBACK'.

      add_word 'ROUND'.

      add_word 'ROWS'.

      add_word 'RTTI'.

      add_word 'RUN'.

      add_word 'SCAN'.

      add_word 'SCAN'.

      add_word 'SCREEN'.

      add_word 'SEARCH'.

      add_word 'SECTION'.

      add_word 'SEPARATED'.

      add_word 'SCROLL'.

      add_word 'SCROLL-BOUNDARY'.

      add_word 'SEARCH'.

      add_word 'SELECT'.

      add_word 'SELECT-OPTIONS'.

      add_word 'SELECTION-SCREEN'.

      add_word 'SELECTION-TABLE'.

      add_word 'SET'.

      add_word 'SHARED'.

      add_word 'SHIFT'.

      add_word 'SIGN'.

      add_word 'SIN'.

      add_word 'SINGLE'.

      add_word 'SINH'.

      add_word 'SIZE'.

      add_word 'SKIP'.

      add_word 'SORT'.

      add_word 'SORTED'.

      add_word 'SPLIT'.

      add_word 'SQL'.

      add_word 'SQRT'.

      add_word 'STAMP'.

      add_word 'STANDARD'.

      add_word 'START-OF-SELECTION'.

      add_word 'STATICS'.

      add_word 'STOP'.

      add_word 'STRUCTURE'.

      add_word 'SUBMIT'.

      add_word 'SUBTRACT'.

      add_word 'SUBTRACT-CORRESPONDING'.

      add_word 'SUM'.

      add_word 'SUPPLY'.

      add_word 'SUPPRESS'.

      add_word 'SYMBOL'.

      add_word 'SYNTAX-CHECK'.

      add_word 'SYNTAX-TRACE'.

      add_word 'SYSTEM-CALL'.

      add_word 'SYSTEM-EXCEPTIONS'.

      add_word 'TABLE'.

      add_word 'TABLE_LINE'.

      add_word 'TABLES'.

      add_word 'TAN'.

      add_word 'TANH'.

      add_word 'TEXT'.

      add_word 'TEXTPOOL'.

      add_word 'TIME'.

      add_word 'TIMES'.

      add_word 'TITLE'.

      add_word 'TITLEBAR'.

      add_word 'TO'.

      add_word 'TOP-OF-PAGE'.

      add_word 'TRANSACTION'.

      add_word 'TRANSFER'.

      add_word 'TRANSLATE'.

      add_word 'TRANSPORTING'.

      add_word 'TRUNC'.

      add_word 'TYPE'.

      add_word 'TYPE-POOL'.

      add_word 'TYPE-POOLS'.

      add_word 'TYPES'.

      add_word 'ULINE'.

      add_word 'UNDER'.

      add_word 'UNIQUE'.

      add_word 'UNIT'.

      add_word 'UNPACK'.

      add_word 'UP'.

      add_word 'UPDATE'.

      add_word 'USER-COMMAND'.

      add_word 'USING'.

      add_word 'UPPER'.

      add_word 'VALUE'.

      add_word 'VALUE-REQUEST'.

      add_word 'VALUES'.

      add_word 'VARY'.

      add_word 'WHEN'.

      add_word 'WHERE'.

      add_word 'WHILE'.

      add_word 'WINDOW'.

      add_word 'WITH'.

      add_word 'WITH-TITLE'.

      add_word 'WORK'.

      add_word 'WRITE'.

      add_word 'X'.

      add_word 'XSTRING'.

      add_word 'Z'.

      add_word 'ZONE'.

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

      add_word 'TRY'.

      add_word 'ENDTRY'.

      add_word 'RECEIVING'.

      add_word 'REGEX'.

      add_word 'EQ'.

      add_word 'NE'.

      add_word 'LT'.

      add_word 'GT'.

      add_word 'LE'.

      add_word 'GE'.

      add_word 'CO'.

      add_word 'CN'.

      add_word 'CA'.

      add_word 'NA'.

      add_word 'CS'.

      add_word 'NS'.

      add_word 'CP'.

      add_word 'NP'.

      add_word 'FIND'.

      add_word 'FIRST'.

      add_word 'OCCURRENCE'.

      add_word 'MATCH'.

      add_word 'OFFSET'.

      add_word 'LENGTH'.

     

    ENDFORM.                    "words

    Report Program to Upload the Material BOM

    $
    0
    0

    Report Program to Upload the Material BOM

     

    Scenario :

    Uploading the Material BOM into SAP System from external file which may be either Text File ( *.TXT) or Excel File (*.XLS or *.XLSX).It is to be noted that the required file can be uploaded from both the presentation and application server.

    So, in this document I have drafted the report program coding with necessary comments for better understandability.

     

    List of subroutines used:

    Function Module Name

    Usage

    F4_FILENAME

    Open up the file browser in Presentation Server and retrieve the user chosen file name.

    F4_DXFILENAME_TOPRECURSION

    Open up the file browser in Application Server.

    SO_SPLIT_FILE_AND_PATH

    Split up the file name and directory name

    TEXT_CONVERT_XLS_TO_SAP

    Upload the contents in XLS file into Internal Table

    GUI_UPLOAD

    Upload the contents in TEXT file into Internal Table

    BAPI_MATERIAL_BOM_GROUP_CREATE

    BAPI to create Material BOM

    Z_ERPSDFM_STATUS_REPORT

    Custom Function Module to display the summary report in ALV Format.

    BAPI_TRANSACTION_COMMIT

    Committing the changes into Database.

     

    Method Name

    Usage

    cl_gui_frontend_services=>directory_exist

    Directory Existence Check

    cl_gui_frontend_services=>file_exist

    File Existence Check

     

    Process Flow:

        1) Upload the Header and Item file.

        2) Read the contents in the header file, and item file. The key for both the files must be Material Number.

        3) Fill up the necessary internal tables used as Exporting Parameter in BAPI_MATERIAL_BOM_GROUP_CREATE.

        4) After  SY_SUBRC check up, using the custom function module the Summary report is displayed in ALV Format.

     

     

    Coding:

    ********** ***************************Main Program********** *********************

    INCLUDE z_gsesdpi_bom_upload_top.
    INCLUDE z_gsesdpi_bom_upload_logic.


    AT SELECTION-SCREEN ON VALUE-REQUEST FOR h_file.
    IF r_app = 'X'.
    PERFORM get_filename_app CHANGING dgv_filename.
    h_file
    = dgv_filename.
    ELSE.
    PERFORM : get_filename CHANGING h_file.
    ENDIF.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR i_file.
    IF r_app = 'X'.
    PERFORM get_filename_app CHANGING dgv_filename.
    i_file
    = dgv_filename.

    ELSE.
    PERFORM : get_filename CHANGING i_file.
    dgv_item_filename
    = i_file.
    ENDIF.

    START-OF-SELECTION.

    * Subroutines to check the filenames.
    PERFORM : file_name_mandatory_check,
    file_ext_check
    USING h_file,
    file_ext_check
    USING i_file.
    IF r_app <> 'X'.
    PERFORM : file_name_validate USING h_file,
    file_name_validate
    USING i_file.
    ENDIF.
    * Subroutines for uploading the contents of external files into internal tbl
    dgv_header_filename
    = h_file.
    PERFORM file_upload USING dgv_header_filename
    dgw_header_file
    CHANGING dgmst_header_file.
    dgv_item_filename
    = i_file.
    PERFORM file_upload USING dgv_item_filename
    dgw_item_file
    CHANGING dgmst_item_file.
    * Subroutines for filling the BAPI fields and executing the same.
    PERFORM : fill_bapi_details,
    display_alv
    .

    ********** ***************************Top Include********** *********************

    *** Type Pool declaration
    TYPE-POOLS : slis ,
    truxs
    .

    TYPES : BEGIN OF dgmss_header_file,
    *** BOMGROUP Table Fields ****
    identifier                       
    TYPE matnr,
    bom_group_identification         
    TYPE cs_bgr_id,
    technical_type                   
    TYPE tetyp_d,
    bom_usage                         
    TYPE stlan,
    bom_group                         
    TYPE exstl,
    created_in_plant                 
    TYPE wrkan,
    auth_group                       
    TYPE stlbe,
    ltxt_lang                         
    TYPE c LENGTH 1,
    langu_iso                         
    TYPE laiso,
    bom_text                         
    TYPE cstext,
    *** MATERIAL RELATIONS Table Fields ***
    plant                             
    TYPE werks_d,
    alternative_bom                   
    TYPE stalt,
    lot_size_from                     
    TYPE c LENGTH 17,
    lot_size_to                       
    TYPE c LENGTH 17,
    material_external                 
    TYPE mgv_material_external,
    material_guid                     
    TYPE mgv_material_guid,
    material_version                 
    TYPE mgv_material_version,
    *** VARIANTS Table Fields ***
    bom_status                       
    TYPE c LENGTH 2,
    deletion_ind                     
    TYPE loknz,
    base_qty                         
    TYPE c LENGTH 17,
    base_unit                         
    TYPE c LENGTH 3,
    base_unit_iso                     
    TYPE isocd_unit,
    lab_design                       
    TYPE labor,
    alt_text                         
    TYPE stktx,
    valid_from_date                   
    TYPE c LENGTH 10,
    change_no                         
    TYPE aennr,
    function                          TYPE cs_function,
    *** TEXTS Table ***
    format_col                       
    TYPE tdformat,
    text_line                         
    TYPE tdline,
    END OF dgmss_header_file,

    *** ITEM Table
    BEGIN OF dgmss_item_file,
    identifier                       
    TYPE matnr,
    item_id                           
    TYPE cs_itmid,
    item_no                           
    TYPE sposn,
    item_cat                         
    TYPE postp,
    res_item_cat                     
    TYPE potpr,
    sort_string                       
    TYPE sortp,
    component                          TYPE idnrk,
    document_type                     
    TYPE dokar,
    document_number                   
    TYPE doknr,
    document_version                 
    TYPE dokvr,
    document_part                     
    TYPE doktl_d,
    class_type                       
    TYPE klassenart,
    class_num                         
    TYPE klasse_d,
    reqd_comp                         
    TYPE clobk,
    sel_cond                         
    TYPE cs_kzclb,
    multselect                       
    TYPE clmult,
    ltxt_lang                         
    TYPE c LENGTH 1,
    langu_iso                         
    TYPE laiso,
    item_text1                       
    TYPE potx1,
    item_text2                       
    TYPE potx2,
    comp_qty                         
    TYPE c LENGTH 18,
    comp_unit                         
    TYPE c LENGTH 3,
    comp_unit_iso                     
    TYPE isocd_unit,
    fixed_qty                         
    TYPE fmnge,
    vsi_no                           
    TYPE c LENGTH 17,
    vsi_size1                         
    TYPE c LENGTH 17,
    vsi_size2                         
    TYPE c LENGTH 17,
    vsi_size3                         
    TYPE c LENGTH 17,
    vsi_size_unit                     
    TYPE c LENGTH 3,
    vsi_size_unit_iso                 
    TYPE isocd_unit,
    vsi_qty                           
    TYPE c LENGTH 17,
    vsi_formula                       
    TYPE rform,
    comp_scrap                       
    TYPE c LENGTH 6,
    opr_scrap                         
    TYPE c LENGTH 6,
    net_scrap_ind                     
    TYPE netau,
    spare_part                       
    TYPE erskz,
    mat_provision                     
    TYPE beikz,
    eng_rel                           
    TYPE sanko,
    prod_rel                         
    TYPE sanfe,
    pm_rel                           
    TYPE sanin,
    pm_assembly                       
    TYPE stkkz,
    cost_rel                         
    TYPE cs_sanka,
    sales_rel                         
    TYPE rvrel,
    bulk_mat                         
    TYPE schgt,
    pur_group                         
    TYPE ekgrp,
    purch_org                         
    TYPE ekorg,
    delivery_days                     
    TYPE c LENGTH 3,
    vendor_no                         
    TYPE lifnr,
    gr_pr_time                       
    TYPE c LENGTH 3,
    price                             
    TYPE c LENGTH 14,
    currency                          TYPE c LENGTH 5,
    currency_iso                     
    TYPE isocd,
    price_unit                       
    TYPE c LENGTH 6,
    rec_allowed                       
    TYPE rekrs,
    lead_time_offset                 
    TYPE c LENGTH 4,
    distr_key_for_comp_consumption   
    TYPE sa_verti,
    purity                           
    TYPE c LENGTH 6,
    co_product                       
    TYPE kzkup,
    iss_st_loc                       
    TYPE cslgo,
    alt_item_strategy                 
    TYPE cs_alpst,
    alt_item_prio                     
    TYPE c LENGTH 2,
    alt_item_group                   
    TYPE cs_alpgr,
    usage_prob                       
    TYPE c LENGTH 3,
    cost_element                     
    TYPE sakto,
    follow_up_group                   
    TYPE cs_nfgrp,
    discon_group                     
    TYPE cs_nfeag,
    supplyarea                       
    TYPE prvbe,
    spproctype                       
    TYPE cs_sobsl,
    expl_type                         
    TYPE cs_dispo,
    lead_time_offset_opr             
    TYPE c LENGTH 4,
    lead_time_offset_opr_unit         
    TYPE c LENGTH 3,
    lead_time_offset_opr_unit_iso     
    TYPE isocd_unit,
    ref_point                         
    TYPE cn_rfpnt,
    valid_from_date                   
    TYPE c LENGTH 10,
    change_no                         
    TYPE aennr,
    component_external               
    TYPE mgv_component_external,
    component_guid                   
    TYPE mgv_component_guid,
    component_version                 
    TYPE mgv_component_version,
    END OF dgmss_item_file.

    DATA : dgmss_commit_return    TYPE bapiret2.
    *** Table Declaration

    DATA : dgmst_bomgroup        TYPE TABLE OF bapi1080_bgr_c,
    dgmst_variants       
    TYPE TABLE OF bapi1080_bom_c,
    dgmst_items           
    TYPE TABLE OF bapi1080_itm_c,
    dgmst_material       
    TYPE TABLE OF bapi1080_mbm_c,
    dgmst_itemassignments 
    TYPE TABLE OF bapi1080_rel_itm_bom_c,
    dgmst_texts           
    TYPE TABLE OF bapi1080_txt_c,
    dgmst_return         
    TYPE TABLE OF bapiret2,
    dgmst_header_file     
    TYPE TABLE OF dgmss_header_file,
    dgmst_item_file       
    TYPE TABLE OF dgmss_item_file,
    dgmst_output         
    TYPE ZERPSDTTOUTPUT,
    dgmst_conv_tab       
    TYPE truxs_t_text_data.

    *** Work Area Declaration

    DATA : dgw_header_file        LIKE LINE OF dgmst_header_file,
    dgw_item_file         
    LIKE LINE OF dgmst_item_file,
    dgw_bomgroup         
    LIKE LINE OF dgmst_bomgroup,
    dgw_variants         
    LIKE LINE OF dgmst_variants,
    dgw_items             
    LIKE LINE OF dgmst_items,
    dgw_material         
    LIKE LINE OF dgmst_material,
    dgw_itemassignments   
    LIKE LINE OF dgmst_itemassignments,
    dgw_texts             
    LIKE LINE OF dgmst_texts,
    dgw_return           
    LIKE LINE OF dgmst_return,
    dgw_output           
    LIKE LINE OF dgmst_output,
    dgw_cellcolor         
    TYPE lvc_s_scol.

    *** Selection Screen Declaration

    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-014.
    SELECTION-SCREEN SKIP.
    PARAMETERS : h_file    TYPE  rlgrap-filename.
    SELECTION-SCREEN SKIP.
    PARAMETERS : i_file    TYPE  rlgrap-filename.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN END OF BLOCK blk1.

    SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-013.
    SELECTION-SCREEN SKIP.
    PARAMETERS r_app    RADIOBUTTON GROUP grp USER-COMMAND DU.
    PARAMETERS r_pre    RADIOBUTTON GROUP grp DEFAULT 'X'.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN END OF BLOCK blk2.

    *** Data declaration

    DATA : dgv_filename        TYPE dxfields-longpath,
    dgv_header_filename 
    TYPE string,
    dgv_item_filename   
    TYPE string,
    dgv_sno             
    TYPE ZREC_COUNT,
    dgv_total_rec       
    TYPE ZREC_COUNT,
    dgv_error_rec       
    TYPE ZREC_COUNT,
    dgv_xls_pos         
    TYPE sy-fdpos,
    dgv_xlsx_pos       
    TYPE sy-fdpos,
    dgv_txt_pos         
    TYPE sy-fdpos,
    dgv_xls_check       
    TYPE c LENGTH 1.

    *** Constants Declaration

    CONSTANTS : dgk_obj_type_bgr TYPE string VALUE 'BGR',
    dgk_obj_type_bom
    TYPE string VALUE 'BOM',
    dgk_obj_type_itm
    TYPE string VALUE 'ITM',
    dgk_obj_id_bgr 
    TYPE string VALUE 'ID_BGR',
    dgk_obj_id_itm 
    TYPE string VALUE 'ID_ITEM',
    dgk_obj_id_bom 
    TYPE string VALUE 'ID_BOM',
    dgk_sno         
    TYPE string VALUE 'SNO',
    dgk_matnr       
    TYPE string VALUE 'MATNR',
    dgk_bom         
    TYPE string VALUE 'BOM',
    dgk_status     
    TYPE string VALUE 'STATUS',
    dgk_description 
    TYPE string VALUE 'DESCRIPTION',
    dgk_xls         
    TYPE string VALUE '.xls',
    dgk_xlsx       
    TYPE string VALUE '.xlsx',
    dgk_txt         
    TYPE string VALUE '.txt'.

    ***************************************Logic***************************************

    FORM file_name_mandatory_check.

    *  Checking whether the given input file is empty and displaying appropriate error message
    IF h_file IS INITIAL.
    MESSAGE s011.
    STOP.
    ENDIF.
    IF i_file IS INITIAL.
    MESSAGE s012.
    STOP.
    ENDIF.

    ENDFORM.                    "file_name_mandatory_check
    *&---------------------------------------------------------------------*
    *&      Form  get_filename
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    *      -->S_FILENAME text
    *----------------------------------------------------------------------*
    FORM get_filename CHANGING s_filename TYPE rlgrap-filename.

    *  Function Module used to open up the file browser in presentation server.
    *                                  and retrieve the user choosen file name.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name 
    = sy-repid
    dynpro_number
    = syst-dynnr
    IMPORTING
    file_name   
    = s_filename.

    ENDFORM.                    "get_filename

    *&---------------------------------------------------------------------*
    *&      Form  file_ext_check
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    *      -->S_FILENAME text
    *----------------------------------------------------------------------*
    FORM file_ext_check USING s_filename TYPE rlgrap-filename.

    SEARCH s_filename FOR dgk_txt. " Searching the file name for string '.txt'.
    MOVE sy-fdpos TO dgv_txt_pos" Moving the position of the found string to a variable
    SEARCH s_filename FOR dgk_xls. " Searching the file name for string '.xls'.
    MOVE sy-fdpos TO dgv_xls_pos.
    SEARCH s_filename FOR dgk_xlsx." Searching the file name for string '.xlsx'.
    MOVE sy-fdpos TO dgv_xlsx_pos.
    IF dgv_txt_pos  = 0 AND        " Neither 'txt' nor 'xls' files have been choosen.
    dgv_xls_pos 
    = 0 AND
    dgv_xlsx_pos
    = 0.
    MESSAGE s010.
    STOP.
    ENDIF.
    IF dgv_xls_pos <> 0 OR dgv_xlsx_pos <> 0. " if 'xls' or 'xlsx' file has been choosen.
    MOVE 'X' TO dgv_xls_check.
    ENDIF.

    ENDFORM.                    "file_ext_check

    *&---------------------------------------------------------------------*
    *&      Form  get_filename_app
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    *      -->S_FILENAME text
    *----------------------------------------------------------------------*
    FORM get_filename_app CHANGING s_filename TYPE dxfields-longpath.

    *  Function Module to open up the file browser for application server.
    CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
    EXPORTING
    i_location_flag     
    = 'A'
    *  I_SERVER              = '?'
    *  I_PATH                =
    filemask             
    = '*.*'
    *  FILEOPERATION        = 'R'
    IMPORTING
    *  O_LOCATION_FLAG      =
    *  O_SERVER              = dlv_o_server
    o_path               
    = s_filename
    *  ABEND_FLAG            =
    EXCEPTIONS
    rfc_error           
    = 1
    error_with_gui       
    = 2
    OTHERS                = 3
    .
    ENDFORM.                    "get_filename_app

    *&---------------------------------------------------------------------*
    *&      Form  file_name_validate
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    FORM file_name_validate USING s_filename.

    DATA : dlv_filename TYPE string,
    dlv_dirname 
    TYPE string,
    dlv_result 
    TYPE c LENGTH 1.
    *  Function Module to split up the file name and directory name.
    CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
    EXPORTING
    full_name   
    = s_filename
    IMPORTING
    stripped_name
    = dlv_filename
    file_path   
    = dlv_dirname
    EXCEPTIONS
    x_error     
    = 1
    OTHERS        = 2.

    IF sy-subrc = 0.
    *    Directory existence check
    CALL METHOD cl_gui_frontend_services=>directory_exist
    EXPORTING
    directory           
    = dlv_dirname
    RECEIVING
    result             
    = dlv_result
    EXCEPTIONS
    cntl_error         
    = 1
    error_no_gui       
    = 2
    wrong_parameter     
    = 3
    not_supported_by_gui
    = 4
    OTHERS              = 5.
    IF dlv_result IS INITIAL.
    MESSAGE s008.
    STOP.
    ENDIF.

    *    File Existence Check
    CLEAR  dlv_result.
    CALL METHOD cl_gui_frontend_services=>file_exist
    EXPORTING
    file               
    = dlv_filename
    RECEIVING
    result             
    = dlv_result
    EXCEPTIONS
    cntl_error         
    = 1
    error_no_gui       
    = 2
    wrong_parameter     
    = 3
    not_supported_by_gui
    = 4
    OTHERS              = 5.
    IF dlv_result IS INITIAL.
    MESSAGE s009.
    STOP.
    ENDIF.
    ENDIF.

    ENDFORM.                    "file_name_validate

    *&---------------------------------------------------------------------*
    *&      Form  file_upload
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    FORM file_upload  USING    dlv_filename
    value(dlw_tab)
    CHANGING dlmst_tab TYPE STANDARD TABLE .

    IF r_app = 'X'.                        " If the Application Server Radio Button has been choosen.
    OPEN DATASET dlv_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc = 8.      " File not found in application server.
    MESSAGE s009.
    STOP.
    ELSEIF sy-subrc = 0.
    DO.
    READ DATASET dlv_filename INTO dlw_tab.
    IF sy-subrc = 0.
    APPEND dlw_tab TO dlmst_tab.
    CLEAR dlw_tab.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    ENDIF.
    CLOSE DATASET h_file.
    ELSEIF dgv_xls_check = 'X'.            " If 'XLS' file has been choosen.
    DATA dlv_filename_xls TYPE rlgrap-filename.
    dlv_filename_xls
    = dlv_filename.
    *    Function module to upload the contents in XLS file into an internal table.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    i_tab_raw_data     
    = dgmst_conv_tab
    i_filename         
    = dlv_filename_xls
    TABLES
    i_tab_converted_data
    = dlmst_tab
    EXCEPTIONS
    conversion_failed   
    = 1
    OTHERS              = 2.
    ELSE.
    *    Function module to upload the contents in TXT file into an internal table.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename               
    = dlv_filename
    filetype               
    = 'ASC'
    has_field_separator   
    = 'X'
    TABLES
    data_tab               
    = dlmst_tab
    EXCEPTIONS
    file_open_error       
    = 1
    file_read_error       
    = 2
    no_batch               
    = 3
    gui_refuse_filetransfer
    = 4
    invalid_type           
    = 5
    no_authority           
    = 6
    unknown_error         
    = 7
    bad_data_format       
    = 8
    header_not_allowed     
    = 9
    separator_not_allowed 
    = 10
    header_too_long       
    = 11
    unknown_dp_error       
    = 12
    access_denied         
    = 13
    dp_out_of_memory       
    = 14
    disk_full             
    = 15
    dp_timeout             
    = 16
    OTHERS                  = 17.
    ENDIF.

    ENDFORM.                    "file_upload


    *&---------------------------------------------------------------------*
    *&      Form  fill_bapi_details
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    FORM fill_bapi_details.

    SORT dgmst_item_file BY identifier.
    LOOP AT dgmst_item_file INTO dgw_item_file" Looping the item file

    AT NEW identifier.                          " At new Identifier, record has to be read from Header file.
    READ TABLE dgmst_header_file INTO dgw_header_file WITH KEY identifier = dgw_item_file-identifier BINARY SEARCH.
    IF sy-subrc = 0.
    PERFORM fill_data.
    ENDIF.
    ENDAT.
    MOVE-CORRESPONDING dgw_item_file TO dgw_items.
    MOVE : dgw_header_file-bom_group_identification  TO dgw_items-bom_group_identification,
    dgk_obj_type_itm                         
    TO dgw_items-object_type,
    dgk_obj_id_itm                           
    TO dgw_items-object_id.
    APPEND dgw_items TO dgmst_items.
    CLEAR dgw_items.

    AT END OF identifier.
    PERFORM : call_bapi,
    refresh_tables
    .
    ENDAT.
    ENDLOOP.

    ENDFORM.                    "fill_bapi_details

    *&---------------------------------------------------------------------*
    *&      Form  fill_data
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    FORM fill_data.
    *  Filling BOMGROUP Table
    MOVE dgw_header_file-bom_group_identification  TO dgw_bomgroup-bom_group_identification,
    dgk_obj_type_bgr                         
    TO dgw_bomgroup-object_type,
    dgk_obj_id_bgr                           
    TO dgw_bomgroup-object_id,
    dgw_header_file
    -technical_type            TO dgw_bomgroup-technical_type,
    dgw_header_file
    -bom_usage                  TO dgw_bomgroup-bom_usage,
    dgw_header_file
    -bom_group                  TO dgw_bomgroup-bom_group,
    dgw_header_file
    -created_in_plant          TO dgw_bomgroup-created_in_plant,
    dgw_header_file
    -auth_group                TO dgw_bomgroup-auth_group,
    dgw_header_file
    -ltxt_lang                  TO dgw_bomgroup-ltxt_lang,
    dgw_header_file
    -langu_iso                  TO dgw_bomgroup-langu_iso,
    dgw_header_file
    -bom_text                  TO dgw_bomgroup-bom_text.

    APPEND dgw_bomgroup TO dgmst_bomgroup.
    CLEAR dgw_bomgroup.
    *******
    *  Filling Material Relations Table
    MOVE dgw_header_file-bom_group_identification  TO dgw_material-bom_group_identification,
    dgw_header_file
    -identifier                TO dgw_material-material,
    dgw_header_file
    -plant                      TO dgw_material-plant,
    dgw_header_file
    -bom_usage                  TO dgw_material-bom_usage,
    dgw_header_file
    -alternative_bom            TO dgw_material-alternative_bom,
    dgw_header_file
    -lot_size_from              TO dgw_material-lot_size_from,
    dgw_header_file
    -lot_size_to                TO dgw_material-lot_size_to,
    dgw_header_file
    -material_external          TO dgw_material-material_external,
    dgw_header_file
    -material_guid              TO dgw_material-material_guid,
    dgw_header_file
    -material_version          TO dgw_material-material_version.

    APPEND dgw_material TO dgmst_material.
    CLEAR  dgw_material.
    *******

    *  Filling Variants Table
    MOVE dgw_header_file-bom_group_identification  TO dgw_variants-bom_group_identification,
    dgk_obj_type_bom                         
    TO dgw_variants-object_type,
    dgk_obj_id_bom                           
    TO dgw_variants-object_id,
    dgw_header_file
    -alternative_bom            TO dgw_variants-alternative_bom,
    dgw_header_file
    -bom_status                TO dgw_variants-bom_status,
    dgw_header_file
    -deletion_ind              TO dgw_variants-deletion_ind,
    dgw_header_file
    -base_qty                  TO dgw_variants-base_qty,
    dgw_header_file
    -base_unit                  TO dgw_variants-base_unit,
    dgw_header_file
    -base_unit_iso              TO dgw_variants-base_unit_iso,
    dgw_header_file
    -lab_design                TO dgw_variants-lab_design,
    dgw_header_file
    -alt_text                  TO dgw_variants-alt_text,
    dgw_header_file
    -change_no                  TO dgw_variants-change_no,
    dgw_header_file
    -function                  TO dgw_variants-function.

    IF dgw_header_file-valid_from_date = ' '.
    MOVE sy-datum TO dgw_variants-valid_from_date.
    ELSE.
    MOVE dgw_header_file-valid_from_date TO dgw_variants-valid_from_date.
    ENDIF.

    APPEND dgw_variants TO dgmst_variants.
    CLEAR dgw_variants.
    *******

    * Filling Texts Table
    IF dgw_header_file-text_line IS NOT INITIAL.
    MOVE dgw_header_file-bom_group_identification  TO dgw_texts-bom_group_identification,
    dgk_obj_type_bgr                         
    TO dgw_texts-object_type,
    dgk_obj_id_bgr                           
    TO dgw_texts-object_id,
    dgw_header_file
    -format_col                TO dgw_texts-format_col,
    dgw_header_file
    -text_line                  TO dgw_texts-text_line.

    APPEND dgw_texts TO dgmst_texts.
    CLEAR dgw_texts.
    ENDIF.
    *******

    * Filling Item Assignments Table
    MOVE dgw_header_file-bom_group_identification  TO dgw_itemassignments-bom_group_identification,
    dgk_obj_type_itm                         
    TO dgw_itemassignments-sub_object_type,
    dgk_obj_id_itm                           
    TO dgw_itemassignments-sub_object_id,
    dgk_obj_type_bom                         
    TO dgw_itemassignments-super_object_type,
    dgk_obj_id_bom                           
    TO dgw_itemassignments-super_object_id,
    dgw_header_file
    -change_no                  TO dgw_itemassignments-change_no,
    dgw_header_file
    -function                  TO dgw_itemassignments-function.

    IF dgw_header_file-valid_from_date = ' '.
    MOVE sy-datum TO dgw_itemassignments-valid_from_date.
    ELSE.
    MOVE dgw_header_file-valid_from_date TO dgw_itemassignments-valid_from_date.
    ENDIF.

    APPEND dgw_itemassignments TO dgmst_itemassignments.
    CLEAR dgw_itemassignments.
    *******
    ENDFORM.                    "fill_data

    *&---------------------------------------------------------------------*
    *&      Form  call_bapi
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    FORM call_bapi.

    DESCRIBE TABLE dgmst_header_file LINES dgv_total_rec.    " Total number of records in header file.

    CALL FUNCTION 'BAPI_MATERIAL_BOM_GROUP_CREATE'          " BAPI to create the Material BOM.
    EXPORTING
    all_error       
    = 'X'
    TABLES
    bomgroup         
    = dgmst_bomgroup
    variants         
    = dgmst_variants
    items           
    = dgmst_items
    materialrelations
    = dgmst_material
    itemassignments 
    = dgmst_itemassignments
    texts           
    = dgmst_texts
    return            = dgmst_return.

    ADD 1 TO dgv_sno.                                      " Incrementing the counter variable.
    MOVE : dgv_sno                    TO dgw_output-sno,
    dgw_header_file
    -identifier TO dgw_output-input_1.

    * Looping the return table, to fetch the error messages.
    LOOP AT dgmst_return INTO dgw_return.

    MOVE dgw_return-message        TO dgw_output-description.

    IF dgw_return-type EQ 'I'.
    MOVE : text-010                TO dgw_output-status,    " 'SUCCESS' is moved to status field.
    dgw_return
    -message_v2  TO dgw_output-input_2" BOM Number is moved to BOM field.
    ELSEIF dgw_return-type EQ 'E'.
    ADD 1 TO dgv_error_rec.
    MOVE : text-011                TO dgw_output-status,    " 'ERROR' is moved to status field.
    dgk_status             
    TO dgw_cellcolor-fname" Field name which is to be  colored is moved.
    '6'                    TO dgw_cellcolor-color-col. " Color Code 6 - RED.
    APPEND dgw_cellcolor TO dgw_output-cellcolor.
    CLEAR dgw_cellcolor.
    ELSE.
    CONTINUE.
    ENDIF.

    APPEND dgw_output TO dgmst_output.
    CLEAR dgw_output.

    PERFORM transaction_commit.
    ENDLOOP.
    ENDFORM.                    "call_bapi

    *&---------------------------------------------------------------------*
    *&      Form  display_alv
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    FORM display_alv.

    * Custom Function Module to display the Summary report in ALV format.
    CALL FUNCTION 'Z_ERPSDFM_STATUS_REPORT'
    EXPORTING
    total_rec   
    = dgv_total_rec
    error_rec   
    = dgv_error_rec
    input_1     
    = 'Material Number'
    input_2     
    = 'BOM'
    CHANGING
    output      = dgmst_output
    EXCEPTIONS
    empty_output
    = 1
    OTHERS      = 2.
    IF sy-subrc = 1.
    MESSAGE s007.
    STOP.
    ENDIF.

    ENDFORM.                    "display_alv
    *&---------------------------------------------------------------------*
    *&      Form  refresh_tables
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    FORM refresh_tables.
    REFRESH : dgmst_bomgroup,
    dgmst_material
    ,
    dgmst_variants
    ,
    dgmst_texts
    ,
    dgmst_itemassignments
    ,
    dgmst_items
    ,
    dgmst_return
    .
    ENDFORM.                    "refresh_tables

    *&---------------------------------------------------------------------*
    *&      Form  transaction_commit
    *&---------------------------------------------------------------------*
    *      text
    *----------------------------------------------------------------------*
    FORM transaction_commit.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    IMPORTING
    return = dgmss_commit_return.
    IF dgmss_commit_return-type = 'E'.
    MESSAGE a001.
    ENDIF.
    ENDFORM.                    "transaction_commit

     

     

    Output:

    Output.JPG

     

    There are lot more standard coding to display in Standard SAP ALV Report Summary format, but still the custom function module for displaying the report summary in ALV format has been given. Please find the details of it in the attachments.

     

    NOTE:  Sample Input files have been attached. But,please prepare the header and item input file with file structure based on the structure declaration in the                    top include corresponding to both Header and Item file.

    Creation of Custom Kernel BADI and Calling it in a Custom Program

    $
    0
    0

    The BADI(Business Add-in's) is an object-oriented enhancement option. The BADI defines an interface that can be implemented by BADI-implementations that are transport objects of their own. The new BADI or Kernel BADI is fully integrated into the Enhancement Framework. Within the Enhancement Framework a BADI is an enhancement option or an anchor point for an object plug-in.

     

    Kernel BAdI's Features

    • Are integrated directly in the ABAP Language/Runtime
    • Improved filter support allows non-character filter types and complex filter conditions
    • Enable reusable implementation instances (Stateful BAdI)
    • Control of the lifetime of implementations (BAdI-context)
    • Allow for inheritance of implementations
    • Can be switched by the Switch Framework

     

    In this document, I have demonstrated the various steps for creating a Kernel BADI and calling it in our own Custom program.

     

    1. First  create a  Enhancement spot from SE18. Kernel Badi's belong to an enhancement spot.

    Enhancement spots carry information about the positions at which enhancement options were created. One enhancement spot can manage several enhancement options of a Repository object. Conversely, several enhancement spots can be assigned to one enhancement option.

     

     

    Enter the description and if you want you can assign the new enhancement spot to a composite enhancement spot. Composite enhancement spots are used for the semantic grouping of simple enhancement spots. A composite enhancement spot contains either one or more simple enhancement spots and/or one or more composite enhancement spots of the relevant type. You can use composite enhancement spots to combine simple enhancement spots into meaningful units.

     

     

    2. On creating the Enhancement spot, you will be directed to Enhancement Spot Editor. Now we need to create a new BADI Definition.

     

     

     

    3. Click on the create BADI button.

     

     

    4. You will find certain options for the BADI definitions as below.

     

     


    Usability - Multiple use - that is, there can be several active implementations

    Limited Filter Use – This makes the BADI Filter-dependent - that is, you apply a filter value to each method called (for example, a country). A different (active) implementation is then called for each value. Possible filter values are characterized by the filter type.



    Instance Generation Mode - This property controls the instantiation of the object plug-ins during execution of the statement GET BADI.

    The first two specifications define context-free BAdIs.

    Newly Created Instantiation - New object plug-ins are created at each execution of the statement GET BADI.

    Reusing Instantiation - An object plug-in that was used once in the current internal mode is reused, if it is required more than once.

    Context-Dependent Instantiation - A context must be specified for GET BADI. This context controls the instantiation. Only one object plug-in is created for each context and implementing class. Each time there is another GET BADI with the same context, it is reused. A context is an instance of a class that implements the tag interface if_badi_context. The specification takes place in the form of a reference to such an instance.



    Fallback Class - Fallback class for a BADI is used if there is no active BADI implementation. This means: The GET BADI command returns a handle to an instance of the fallback class and the respective CALL BADI calls the methods of the fallback class instance. As soon as there is an active BADI implementation, the fallback class is not used any longer at runtime.


     

     

    5. Now we need to add an interface to the BADI. Expand the Node of BADI definition name and double click on node Interface. You can either add existing interface or will be prompted to create.

     


     

    6. On clicking ‘Yes’, you will be navigated to the below screen, where you can add a method to the new interface.


    Save, activate and comeback to the BADI definition screen and activate the Enhancement Spot.

     

     

    7. Next we need to implement the Enhancement spot and BADI. Right click on the BADI definition and select Create BADI Implementation.

     

     

    8. First the system will ask for enhancement implementation name. Please enter a name and description.

     

     

    9. Next it will ask for BADI Implementation name and Class name for implementing BADI. Enter the names and click ok.

     

     

    10. Next we have to implement the interface method. Expand the BADI Definition name and double click on BADI implementation.

     

     

    11. You will be directed to the enhancement implementation screen, shown below. Double click on the Interface method and you will be prompted to create implementation for the method.


     

    12. On clicking yes, you will be navigated to editor for the method. Add the following code for showing a message or anything as per your requirement. Save it and activate.

     

     

    So the BADI definition and implementation part is complete.

     

    Next we will see how we can call this Kernel BADI in our Custom program.

     

    13. Create or open an existing program in SE38. Point to the line where you need to add enhancement option. Right click and select Create Option.

     

     

    14. Give an Enhancement point or section name and Enhancement spot implementation name. Here I have opted an Enhancement point and have entered Enhancement spot implementation name as ‘ZENH_IMP_TEST’ (which we have created before).

     

     

    A new line will be added to the existing code as shown below.


     

    15. Then add the below code which is shown in the red box below.

     

     

    Apart from Classic BADI’s which are been called by Proxy class cl_exithandler, Kernel BADI’s are called directly with the reference to the BADI definition via GET BADI and CALL BADI statements.  That is one of the reasons why Kernel BADI is faster than classic BADI. Also in Classic BADI, while we call it via cl_exithandler,  we use the reference to the interface rather than BADI definition

     

    16. Now activate the program and execute it. When the cursor reaches the enhancement point, where the BADI is called it will trigger all the active implementations of that BADI. Here we have only one implementation and that will be triggered, which shows the below message as we have written in the BADI implementation.

     

     

    If the program fails to trigger the BADI implementation, please recheck whether everything associated with it is ‘Activated’ after the creation.

     

    Thank You.


    How to Print Barcodes that are not supported by SAP using Smartforms

    $
    0
    0

    Introduction:

     

    In this document we will work on printing a Data Matrix barcode (DMC) which is a 2D barcode not supported by SAP.

     

    A 2D (two-dimensional) barcode is a graphical image that stores information both horizontally -- as one-dimensional bar codes do -- and vertically. As a result of that construction, 2D codes can store up to 7,089 characters and possibly more.

     

    Below are some of the types of 2D barcodes

     

    Capture.PNG

    Requirement:

     

    Print Data Matrix barcode (2D barcode) on zebra printers using Smartform.

     

    * Similar approach can be followed for printing other 2D barcodes and the generic barcodes with specific height and width.

     

    Issue:

     

    SAP by default only supports PDF417 as 2D barcode and does not support Data Matrix and other 2D barcodes

     

    Solution:

     

    Printing other 2D barcodes which are not supported by SAP is possible by following the below steps

     

    • Printer should support the required barcode:We can check this online based on the printer model and make. Most probably you will find this information on the manufacturer’s website.

        

    • Choose an appropriate device type for the printer:Selection of device type is based on the printer you are using.  In this example we are using ZEBRA printer so the device type selction will be based on Zebra printer.This topic is dealt in more detail in the other document named ‘Working with Zebra Printers using Smartforms in SAP’ please refer to the same for additional documentation on selecting the device type for Zebra printers.  For Zebra printers we have the following device types LZEB* (* => 2/3/4) series or YZB# (# => 200/300/400) series based on the DPI resolution of the printer.

            For the demonstration as an example we will use LZEB2 device type from here on in this document.

    • Create a system barcode of type UNDEF in SAP:For creating a system barcode go to transaction SE73.

              This will take you to the SAP script Font Maintenance: Initial screen

            Capture.PNG

              Select System barcodes check box and click the change button. This will display a list of all the Barcodes on the SAP system.

     

              Click the Create button (Paper icon) at the top of the screen

              Capture.PNG

              The Choose Bar Code Technology select box will now be displayed.

              Capture.PNG

              The barcode we are adding is a new barcode symbology which is not supported by SAP, and the new barcode techcnology allows only specif types

              of barcodes symbologies to be created therefore we are going to use Old technology to create our new barcode as an undefined symbology.

     

              So Click on Old.

     

              The Create/Change System Bar Code settings screen will be displayed. For barcode type enter ‘UNDEF’ ( barcode not defined) as the data matrix

              barcode type is not defined in SAP. Also specify the height and width of the barcode.

     

              Capture.PNG

              Then save the changes by clicking on the Ok button. Now the system barcode ZDMC is created.

     

    • Create a printer barcode for the newly created system barcode with appropriate print control:

     

           For creating a system barcode go to transaction SE73. This will take you to the SAP script Font Maintenance: Initial screen

           Capture.PNG

              Select printer barcodes check box and click the change button. This will display a list of device Types available in SAP system.

     

           Capture.PNG

              In this case I am using device type LZEB2 so I will create a printer barcode for this device type. It is advisable to copy this device type to a new

                 device type and then make changes to the new Z device type and use it for printing but for demonstration I am using the same device type.

     

                 Double click on the device type to list the barcodes supported by this device type.

                  Capture.PNG

                   Notice the Prefix and Suffix value ranges used for the barcodes. Here in this case the highest number used for prefix is SBP20 and is different

                   for each barcode however the suffix is same for all the barcodes. These prefix and suffix are the print controls of the barcodes supported by

                   the printer.

     

                   Now select the create button on the top of the screen to add a new printer barcode. This will take you to the barcode selection screen.

                   Capture.PNG

                   Select the system barcode you created earlier and enter the other values as shown in the screenshot above. For prefix we are entering SBP21

                   because all the numbers from 1 -20 (SBP01 to SBP20) are already used so we are using the next available number SBP21 and the suffix number

                   stays the same. We can use any number from 21-99 for prefix.

     

                   Now the barcode is created for the device type (see screen shot  below)

                   Capture.PNG

                   But the print control SBP21 is empty. For the barcode to work properly we have to add commands in the print control in ZPL-II language

                   (printer language).

     

                   Please find the online document named 'ZPL2 command book' . The site link for the same is

                   http://www.zebra.com/id/zebra/na/en/documentlibrary/manuals/en/zpl_ii_programming2.File.tmp/45541L-002_RA.pdf

     

                   It is adviced to have the document before we proceed further. This command book has all the commands for printing different types of

                   barcodes on a printer ( only if the printer supports it )using the ZPL2 command Lanugage.

     

                   Here we are adding the Data matrix barcode, and the printer command format for printing the data matrix is: ^BXo,h,s,c,r,f,g

     

                   Command Parameters:

                   O – Orientation

                   H – Height

                   S – Quality level

                   C – Columns to encode

                   R – Rows to encode

                   F – Format ID

                   G – Escape sequence control character

     

                   Refer to the attached command book for accepted and default values for the above parameters and how to use the command.

     

               Below is an example of the post script language commands used for printing a DMC barcode on the printer.

               Capture.PNG

                The printer command mainly needs to have 3 types of information

    1.      Command to indicate the type of barcode to be printed ( Marked by ^BX in the command above)
    2.        Command to indicator the start of data ( Marked by ^FD)
    3.        Command to indicator the end of data (Marked by ^FS)

     

               When working with Smartforms the prefix print control in the printer barcodes screen should have both the commands for the type of barcode

                   and the command for the start of datawhereas the suffix will only have the command to mark the end of data.

     

               Capture.PNG

              Taking the above points into consideration we will have ^BXN,2,200,20,20,6,~,1^FDcommand in prefix and ^FS in suffix.  As the suffix is

                 used to mark the end of data it is same for all the barcodes and hence maintained as default.

     

                 Meanings of the command Parameters for prefix ^BXN,2,200,20,20,6,~,1^FD are:

                  ^BX        The Data Matrix command

                  N            The orientation is normal

                  2              Dimensional height in dots of the individual symbol elements

                  200         Quality ECC level (ECC 200)

                  20           Columns to encode

                  20           Rows to encode

                  6              Data to be used (6 means full 256 ISO 8-bit data is used)

                  ~             Escape sequence for control characters

                  1              Square aspect ratio, if you required rectangle this will be 2

                  ^FD        This is to mark the start of the field data to be encoded in the barcode

     

                Add the following command in the print control prefix:  ^BXN,2,200,20,20,6,~,1^FD

     

                Go to SE73 -> Select printer barcodes -> Change ->Select device type (in this case LZEB2) -> double click to display the list of barcodes supported

                by the device type.

              Capture.PNG

                  Select the new print control SBP21 (barcode prefix) and click on Maintain Print control button. Following popup will be displayed.

              Capture.PNG

                  Enter the command in the control characters sequence field and make sure the Hexadecimal switch is turned OFF. Then press enter.

                  The print control is saved.

     

                   The barcode suffix SBS00, which is default for all the barcodes holds the end of data command (see below)

               Capture.PNG

                   The configuration of the printer barcode is complete. Now we can use this barcode to print the Data Matrix barcode (2D barcode) from SAP.

     

                   Note:

                   There can be various combinations to the prefix command. If the barcode is not printed then you have to try changing the values for the height,

                   rows and columns variables in the command. The prefix combination that worked for me is: ^BXN,3,200,,,6,~,1^FD

     

                   Capture.PNG

    • Use the barcode in the Smartform using a style:

     

           Please refer to online documentation for adding a barcode to a style in Smartform.

     

           After you have added the barcodes to one of the character formats of the style which is being used in the Smartform, we just have to use the

             newly created barcode type to display the 2D content as Data Matrix Barcode.

     

           See below screenshot for an example.

           Capture.PNG

           As the example depicts, use a separate text node for the 2D barcode , keep all the 2D content in a variable or write it all down in the text node.

             Select the whole text and select the character format for the DMC barcode.

            

              At this point if you try to print the barcode it is expected to see the barcode on the printout, but you might not see the barcode printed on the

             printer, the reason as i understood is that based on the ZPL2 command the data should be marked with the start of data command and End of data

             command along with the type of barcode we are trying to print. so the commands should be inserted before and after the text node that holds

              the 2D data content. This will give the printer a command saying that the data between this is to be printed as the barcode symbology specified in

              the command, in our case Data Matrix.

     

              Note : Preview will not show the barcode because literally this barcode is not in SAP system and will only be printed on the printer. So anything

              concerning the barcode has to be tested on the actual printer not the preview because both the preview and the actual print will be a lot

              different.

     

    • Create a command node before and after the text node that holds the 2D barcode content:

     

           See below screen shots for an example on how to create a command node.

       Capture.PNG

            Then enter the prefix print control we created in the printer control input field (see below).

        Capture.PNG

           Create one more command node under the 2d content text node and enter the enter the suffix print control in the printer control input

             field (see below)

        Capture.PNG

            Now test the print on the Zebra printer, the barcode should be printed on the zebra printer as shown in the screen shot below. Now take the

            printout and scan the barcode with any of the android apps or any barcode reader that support DMC barcode. Please note that the printout taken

            on your local printer from a scanned document wont be readable, so it is advised to test the barcode scanning from the actual printout or from the

            Scanned document on your computer.

           Capture.PNG

            After scanning, the barcode should display all the 2D content .

     

     

    Alignment issues with the 2D barcode:

              After the barcode is printed you might notice alignment issues on the label. To solve the alignment issues the following approach can be used.

     

              Go to Smartstyle you have used in the Smartform, select the respective paragraph format node you have assigned for the barcode. Here try

              changing the alignment and spacing values (see screen shot below) and try giving it a few trials. You will be able to align barcodes after a few

              combinations.

     

              Capture.PNG

     

                   Note:

                   Please make sure you have enough space for the barcode when designing the layout. I mean if you are planning to have a barcode of size

                   1 CM * 1 CM then make use you have a separate window on the layout with space more than the barcode size.

     

     

                                                     ----------------  THE END  -----------------

    Please note that the document is based on my personal experience and the online documentation i came across. So if there is any scope of improvements in this document you are most welcome to add your comments.

     

     

     

         

     

        

    Print Parameter settings for Background jobs to avoid auto spool deletion

    $
    0
    0

    when we schedule the background jobs in SM37, we will be getting spool list by clicking the spool icon but sometimes we use to get the error 'No List available' even though the spool got generated in the system. The reason is that the spool got deleted once the spool is generated in the system and it is giving the Error message as 'No List Available'.
    Below are the ways to avoid the NO LIST AVAILABLE error in the system,
    Step 1: Check the User name of the Job which is running in SU01
    Go to SU01 give the user name and click on the Display, select the tab ˜Defaults'
    Uncheck the check box  ' Delete After Output'
    S1.JPG
    Step 2: Check the Print Specifications in SM37
    Go to SM37 enter the job name and click on execute button
        s2.JPG
    • Select the job which is in released status and change from released status to scheduled
    s3.JPG
    • Select Change from Menu bar to change the job
    s4.JPG
    •   Click on STEP button
            s5.JPG
    • Select the program name and click on change icon
    s6.JPG
    • The below screen will appear
    s7.JPG
    • Click on Printer Specifications, pop-up will appear then Click on Properties Button
    s8.JPG
    • Go to output options and click on the line 'Delete Immediately After Printing' row
    s9.JPG
    • Uncheck the check box  'Delete After Printing' and click OK

            as in the below scrren shot

    s10.JPG
    The above steps will avoid the auto spool deletion in Background Jobs in SM37.
    Author : Bharathipriya N

     

    Inner html table optimization for SO_NEW_DOCUMENT_ATT_SEND_API1 function module

    $
    0
    0

    When you prepare HTML-data for ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ function module it could be convenient to make a new internal table line for each tag (or several tags). Like this:

     

    1.png

    But, this approach has certain drawback. In fact, the greater part of each table line would remain unoccupied. Accordingly, the internal table with HTML code would have been looking like this:

     

    3.png

    But, the line of HTML table has type ‘SOLISTI1’ (CHAR255), consequently, a very large amount of memory remains useless.

    When program started, generated inner table has become inadmissibly spacious.

    So, as there is a limitation that e-mail can’t be heavier than 20 megabytes, it is often impossible to send large e-mails via ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ FM.

     

    To avoid this, it would be expedient to use following function module to optimize inner table with HTML code:

    FUNCTION z_html_optimize.

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

    *"*"Локальный интерфейс:

    *"  IMPORTING

    *"     REFERENCE(WHOLE_WORDS) TYPE  FLAG DEFAULT ' '

    *"     REFERENCE(LINE_LEN) TYPE  INT4 DEFAULT 255

    *"  CHANGING

    *"     REFERENCE(CT_TAB) TYPE  RSPC_T_TEXT

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

      TYPE-POOLS abap.

     

      DATA:

        l_in_len   TYPE i,

        l_free_len TYPE i,

        l_diff     TYPE i,

        ls_out     TYPE solisti1,

        lt_out     TYPE rspc_t_text.

     

      FIELD-SYMBOLS:

        <s_in>LIKELINEOF ct_tab.

     

     

      LOOPAT ct_tab ASSIGNING<s_in>.

        l_in_len  = STRLEN(<s_in>-line ).

        l_free_len = line_len - STRLEN( ls_out-line ).

        IF l_in_len <= l_free_len.

          CONCATENATE ls_out-line <s_in>-line INTO ls_out-line.

          CONDENSE ls_out-line.

        ELSE.

          IF whole_words = abap_true.

            IF l_free_len >= l_in_len.

              CONCATENATE ls_out-line <s_in>-line INTO ls_out-line.

              CONDENSE ls_out-line.

              APPEND ls_out TO lt_out.

              CLEAR ls_out.

            ELSE.

              APPEND ls_out TO lt_out.

              CLEAR ls_out.

              CONCATENATE ls_out-line <s_in>-line INTO ls_out-line.

              CONDENSE ls_out-line.

            ENDIF.

          ELSE.

            IF l_free_len >0.

              CONCATENATE ls_out-line <s_in>-line(l_free_len)INTO ls_out-line.

              CONDENSE ls_out-line.

            ENDIF.

     

            APPEND ls_out TO lt_out.

            CLEAR ls_out.

            IF l_free_len <0.

              l_free_len = 0.

            ENDIF.

            l_diff = l_in_len - l_free_len.

            IF l_diff >0.

              CONCATENATE ls_out-line <s_in>-line+l_free_len(l_diff)INTO ls_out-line.

              CONDENSE ls_out-line.

            ENDIF.

          ENDIF.

        ENDIF.

        ATLAST.

          IF l_in_len <= l_free_len.

            APPEND ls_out TO lt_out.

          ELSE.

            IF whole_words = abap_true.

              APPEND ls_out TO lt_out.

            ELSE.

              IF l_diff >0.

                APPEND ls_out TO lt_out.

              ENDIF.

            ENDIF.

          ENDIF.

        ENDAT.

      ENDLOOP.

     

      ct_tab[] = lt_out[].

     

    ENDFUNCTION.

    If you use it like this:

    2.png

    The inner table would have no useless space:

    4.png

    And it would have allowable weight, so FM ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ would easily send derivable e-mail.

    Display a negative value with signage to the left instead of the right -100.00 not 100.00-

    $
    0
    0

    In the past I have had more than 1 client request that the negative numbers with signage on the right are displayed in ALV reports and / or extracted to files with the signage to the left.

     

    -100.00 NOT100.00-

     

    I decided to create a conversion exit to perform this format conversion, as below. And this then is implemented in my alv / file extract logic.

    conv_exit.jpg

    " ALV field cat coding...apply the conv exit accordingly to the edit_mask attribute...

    ....

    if <fieldcat>-inttype = 'P'.
        <fieldcat>-edit_mask = '==ZSIGD'.
      endif.

    .....

    similarly, if you are extracting the data to a file,

    the conversion can also be called to format the number

    .......

       do.
            assign component sy-index of structure <table_line> to <field>.
            if sy-subrc is initial. "we still processing fields
              clear lv_value.
              describe field <field> type lv_typ1.
              if lv_typ1 = 'D'. " format for date
                yyyymmdd_date_format <field> lv_value.
              elseif lv_typ1 = 'h'.
                move space to lv_value.
              elseif lv_typ1 = 'P'.
                call function 'CONVERSION_EXIT_ZSIGD_OUTPUT'
                  exporting
                    input  = <field>
                  importing
                    output = lv_value.
              else. "all other formats
                move <field> to lv_value.
              endif.

              ">>>build up the row that will be written to the file
              concatenate lv_fileline lv_value into lv_fileline
                separated by cl_abap_char_utilities=>horizontal_tab.

    .......

    Result of ALV
    result.jpg

    Result of File extract

    excel.jpg

    Archive Adobe Form

    $
    0
    0

    Hi All,

     

    Often I get the question to create a Adobe form for showing some data. For multiple reasons, like accessing the PDF by an URL or just to store the PDF, I had to archive the Adobe form in Archivelink. Every time I had to search for the right function modules. So for all of you and myself I put it all together on SCN.

     

    Data declaration:

    DATA: fm_name           TYPE rs38l_fnam,               fp_docparams      TYPE sfpdocparams,             fp_outputparams   TYPE sfpoutputparams,         ls_FORMOUTPUT     TYPE FPFORMOUTPUT,         pdf TYPE xstring,          LS_OUTDOC  TYPE  TOADT,         LT_ARCHIVOBJECT  TYPE TABLE OF DOCS,         LT_BINARCHIVOBJECT  TYPE TABLE OF  TBL1024.

    For archiving the PDF and NOT showing we have to set the following parameter before we move on:

    FP_OUTPUTPARAMS-GETPDF = 'X'.

     

    After this configuration we can open the spool:

    CALL FUNCTION 'FP_JOB_OPEN'                   "& Form Processing: Call Form     CHANGING       ie_outputparams = fp_outputparams     EXCEPTIONS       cancel          = 1       usage_error     = 2       system_error    = 3       internal_error  = 4       OTHERS          = 5.

    Next step is to get the name of the Adobe form. This can change while transporting to another system so you have to use this FM with the name of the Adobe form in SFP:

    CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'           "& Form Processing Generation     EXPORTING       i_name     = 'Z_NAME_OF_PDF_IN_SFP'     IMPORTING       e_funcname = fm_name.

    Then we are ready to call the Adobe form and in case is necessary pass some data:

      fp_docparams-langu   = 'NL'.
    *&--- Call the generated function module   CALL FUNCTION fm_name     EXPORTING       /1bcdwb/docparams        = fp_docparams       data                     = data     IMPORTING      /1BCDWB/FORMOUTPUT       = ls_FORMOUTPUT     EXCEPTIONS       usage_error           = 1       system_error          = 2       internal_error           = 3.

    After this step we can close the spool:

    CALL FUNCTION 'FP_JOB_CLOSE'
    *    IMPORTING
    *     E_RESULT             =     EXCEPTIONS       usage_error           = 1       system_error          = 2       internal_error        = 3       OTHERS               = 4.

    Now we have our generated PDF in ls_formoutput-PDF. Before we archive this PDF we have to do some config, go to SPRO:

    spro.png

    Create a new document type:

    ztype.png

    Link this document type to your SAP object:

    link.png

    All other configurations was already available in my case.

     

    Because I want to overwrite my previouse PDF, I will delete that one first by using the following FM:

    AR_OBJECT is the document type

    OBJECT_ID is the name of the document

    SAP_OBJECT is the object type

    CALL FUNCTION 'ARCHIV_DELETE_META'     EXPORTING
    *     ARCHIV_ID                      = ' '
    *     ARC_DOC_ID                     = ' '      AR_OBJECT                      = 'ZTYPE'      DELETE_FLAG                    = 2       OBJECT_ID                      = 'temp'       SAP_OBJECT                     = 'ZOBJECT'      CLIENT                         = sy-mandt
    *     SINGLE_ENTRY                   = ' '
    *     DOCUMENTCLASS                  =      NO_AUTH_CHECK                  = 'X'
    *   IMPORTING
    *     ALL_CONNECTIONS_DELETED        =    EXCEPTIONS      ERROR_CONNECTIONTABLE          = 1      ERROR_PARAMETER                = 2      ERROR_ARCHIV                   = 3      ERROR_KERNEL                   = 4      ERROR_COMMUNICATIONTABLE       = 5      ERROR_AUTHORITY                = 6      OTHERS                         = 7             .

    Now I'm going to archive my new version with the name temp:

    AR_OBJECT is the document type

    OBJECT_ID is the name of the document

    SAP_OBJECT is the object type

    the tables can stay empty.

    CALL FUNCTION 'ARCHIV_CREATE_TABLE'     EXPORTING       AR_OBJECT                = 'ZTYPE'
    *     DEL_DATE                 =       OBJECT_ID                = 'temp'       SAP_OBJECT               = 'ZOBJECT'
    *     FLENGTH                  =       DOC_TYPE                 = 'PDF'       DOCUMENT                 = ls_FORMOUTPUT-PDF       MANDT                    = SY-MANDT     IMPORTING       OUTDOC                   = LS_OUTDOC     TABLES       ARCHIVOBJECT             = LT_ARCHIVOBJECT       BINARCHIVOBJECT          = LT_BINARCHIVOBJECT     EXCEPTIONS       ERROR_ARCHIV             = 1       ERROR_COMMUNICATIONTABLE = 2       ERROR_CONNECTIONTABLE    = 3       ERROR_KERNEL             = 4       ERROR_PARAMETER          = 5       ERROR_USER_EXIT          = 6       ERROR_MANDANT            = 7       OTHERS                   = 8.

    If everything went well, your document should be stored in Archivlink.

     

    Hope it's helpful!

     

    Kinde regards,

    Wouter

    Viewing all 935 articles
    Browse latest View live


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