Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

 

ABAP - Tips and Tricks Channel

These are a list of tips and tricks that i have experienced on different Projects. These include workarounds for certain limitations, Tips and troubleshooting solutions for overcoming certain problems found in a given project. Each of these solutions would be categorized according to their usage.

Applies to:

ABAP

Author: Fahad Javed

Created on : 27th March 2013

Table Of Contents:

Categories:


[SAP GUI For Windows]:

[01] - Getting an error of 'host name 'NiHLGetNodeAddr' unknown error' when logging in to SAP GUI 7.40:


Issue:

> How can we resolve an error showing up when logging into a system via sap gui 7.40 and i have just updated from sap gui 7.30?

Solution:

This issue shows up when you have upgraded to sap gui 7.40 from sap gui 7.30. What happens is that saplogon.ini file is replaced with the new landscape based format as introduced with NWBC 5.0 and sap gui 7.40. Also refer to sap note '2077230' for more details. Here are the steps you can take to resolve this issue :

> SAP Landscape files when sap gui 7.40 is installed,are stored in the following path:

    C:\Users\<user_name>\AppData\Roaming\SAP\Common

> In case you are updating from sap gui 7.30,it replaces the settings stored in saplogon.ini file to the new system landscape configuration file 'SAPUILandscape.xml'.

> Delete the following files 'SAPUILandscape.xml' and 'SAPUILandscapeGlobal.xml' from the landscape directory.

> A new file will be created,just open the 'SAPUILandscape.xml' file and replace the 4 character /H/" with ".

> Close SAP gui

> start SAP gui and you would be able to logon.

 

[Dynpro's]:

[01] - Creating a checkbox out of a character field in Screen painter

Figure 01_a : Sample table structure

Figure 01_b : Assigning field for
 screen mapping

Figure 01_c : Conversion of character
 field to checkbox

Figure 01_d : Final output of the
screen with a checkbox

Issue:

> How can i create a checkbox in Screen Painter out of a character field?

Solution:

> In order to create a checkbox field,you need to first create a table that needs to be mapped with the screen and provide character field with a length of a single character i.e. '1'. The sample table used is provided in the screen shot.
> Next we will need to create a dialog program and a screen in screenpainter,wit a screen number.
> Next open the screen in layout mode and click on the 'Dictionary/ProgramFieldsWindow'(with a red icon behind a blue background) in the application toolbar or press the 'F6' Shortcut key.
   Next choose the field from the Table,in our case it would be the 'Car License' field.
> In newer versions of SAP,you get a conversion dialog box as shown in the screenshot,as soon as you place a single character field. you can also convert it to checkbox,by first placing it on the screen area(when after selecting the field in the previous step and clicking the Ok button(green check tickmark like button)).

> Next select both the field and its label and right click them and choose:
    Convert > Checkbox > Left Button
                          [OR]    
    Convert > Checkbox > Right Button

You can also choose the menu path as follows,within screen painter:
    Edit > Convert > Checkbox > Left Button
                           [OR]    
    Edit > Convert > Checkbox > Right Button

> Another way to do this is while mapping the field to the screen. By default fields placed on a screen are created as text boxes. you can change this behaviour by selecting the 'checkbox' radio button instead of the default text box and placing the field on the screen,which will already convert this field to a checkbox.


[ABAP - HR]:

[01] - Extending the Infotype Structure length of 2000 characters

Issue:

> I can't add more fields beyond,2000 characters in a custom infotype in SAP HCM.What should i do?

Solution:

> When the you have defined new fields that exceed the 2000 character limit,it will not show any errors but when you try to create a new entry in that infotype and press enter or save it,it will show a dump(screen shot provided).You can do so,by creating all fields that fall within the 2000 character limit and then creating a separate structure that holds the remaining fields. Now you need to include it in your custom infotype by using the '.INCLUDE' directive. Doing so would trick the data dictionary transaction from popping up that 2000 limit message. I have tried this on the NBP(National Bank of Pakistan) project and its has worked for me.


[General]:

[01] - Converting a Spool Request to a PDF File:

Figure 01 : Printing a Report in SAP

Figure 02 : Getting the Spool No of
the Print Job

Figure 03 : Selection of Spool Request
to PDF Program

Figure 04 : Log File

Figure 05 : Final Converted
PDF File

Issue:

> Is there a Standard Program or transaction in SAP that can be used to convert a spool request to a PDF file?

Solution:

> Yes there is a Standard Program named 'RSTXPDFT4'(Converting SAPscript(OTF) or ABAP List Spool Job to PDF)[Note: This program can be executed by pasting its name in the ABAP Editor transaction(SE38)].

All you need to do is generate a spool request for the given print program(be it Standard reports,custom alv,Smartforms or SAP Script),this is usually achieved by clicking the 'Print' button in most reports(Please see the relevant screenshot). After spool generation you need the spool number to use this program. A Spool Number can be easily accessed via the standard SAP menu path:

                              System > Own Spool Requests

                                                 [OR]

                               Use the Transaction named 'SP02'(Output Controller : list of Spool Requests)

Copy the spool number and paste it in the program mentioned above and check the 'Download PDF file' checkbox and execute it. You will be prompted with a dialog box to browse to a particular directory where you want to save the PDF File and click the 'Save' button. You will be shown a log in the end,which shows whether the PDF conversion was successful or not. You can now open the PDF file in your favorite PDF Reader program.


[Enhancements]:

[A - SAP FI(Financials)]:

[A-01] - Creating a Custom Print program for Payment Instruments in SAP FI(Financials)(Transactions = F-58,FBZ5,FBZP)

Issue:

> How do we attach a Custom Print Program with a Smartform,instead of the default SAP Script Program in the SAP FI Payment Instruments(e.g: Payorder,cheque e.t.c) Print Program?

Solution:

> There are various payment instruments available in SAP FI,each of which is denoted technically in sap by the term 'Payment method'. Some of these instruments include 'Cheque Payment','Cash Payment','Payment Order','Bank Transfer PLS','Bank Transfer Current' e.t.c. Cheque and Payorder are the most commonly used instruments. Of course the FI consultant can create custom payment methods and map them to a country,by going to the following menu path in IMG(Customizing):

Financial Accounting(New) > Accounts Receivable and Accounts Payable > Business Transactions > Incoming Payments > Automatic Incoming Payments

> Payment Method/Bank Selection for Payment Program > Set Up Payment Methods per Country for Payment Transactions
> The name of the Standard Print Program for these Payment Instruments is 'RFFOUS_C'. If you look closely at this program,you will find an include named 'RFFORI01',this include program will contain SAP Scrip statements such as 'OPEN_FORM','WRITE_FORM' and 'CLOSE_FORM' e.t.c.,which can easily be opened in SAP Script Form transaction of 'SE71'. For example the default SAP Script attached to a cheque Payment instrument is 'F110_PRENUM_CHCK'. The standard print program 'RFFOUS_S' already contains pre-populated Payment instrument data in the form of structures,that can be added to a custom structure or internal table and passed to a smartform or an SAP Script.

Standard Structures pre-populated with data in the Standard Print Program:

The standard Structures that will be helpful for passing in data,include the following:

(01)REGUH(Settlement data from payment program):

> This structure includes information related to the payment instrument such as:

(A)Vendor or Payee Number(reguh-empfg+1(10),reguh-lifnr)

(B)Vendor or Payee Name(reguh-znme1,reguh-znme2)

(C)Cheque Date(reguh-laufd)

(D)Cheque Amount in Number(reguh-rbetr)[Note: you can use the function module 'SPELL_AMOUNT' for converting the given cheque amount into words]

(E)Bank Document Number(reguh-belnr)

(F)Bank Document Date(reguh-laufd)

(G)Vendor or Payee Address Line(reguh-stras)

(H)Vendor or Payee City(reguh-ort01)

(02)REGUD(Form print transfer data):

> This structure includes information related to the payment instrument such as:

(A)Cheque Number(reguh-chect)[This is basically is the lot number for the payment instrument which is defined as a series by the FI functional Consultant]

(03)PAYR(Payment Medium File):

This structure includes fields such as:

(A)short key for House Bank(payr-HBKID)(This can be used for determining the Payment Instrument being currently used)

(B)Cheque number(payr-CHECT)

(C)Currency key(payr-WAERS)

(D)Print User(payr-PRIUS)

(E)Bank number of the payee's bank(payr-ZBNKL)

(F)Name of the payee(payr-ZNME1)

(G)Title of the payee(payr-ZANRE)

(H)Fiscal Year(payr-GJAHR)

(I)Paying company code(payr-ZBUKR)

[Note]: To see all the fields into these structures,you can enter them in the Data Dictionary Transaction(SE11),to see a list of all the fields.

> The Print Program for these Payment instruments can be invoked in 2 ways:

(01)By posting a document for the given payment methods,you will be prompted to print that,using the Transaction 'F-58'(Payment with Printout:Header Data).

(02)By printing documents that have already been printed using the transaction 'FBZ5'(Print Form for Payment Document).

Procedure for attaching the Smartform in place of the standard Print Program(RFFOUS_C):

> In order to attach the smartform,you need to create a replica of the Standard Print Program(RFFOUS_C) in customer namespace e.g: 'ZRFFOUS_C'.Next you will need to attach this replica in place of the standard program,by going to the Transaction 'FBZP'(Maintain Payment Program) and then click the 'Pmnt methods in country' button,in the position button enter in the 'country code',in our case it is PK(Pakistan) and the 'payment method' lets say 'C'(Cheque payment) Just Double click the payment method for which you want to attach the program. Now in the 'Payment medium' section,copy the name of your custom replica program within the 'Payment medium program' input field,just below the 'Use classic payment medium programs(RFFO)*' radio button and then click the save button to save this. This attaches your custom print program instead of the standard print program.

> You can attach the same custom replica program on all payment methods and use conditional constructs to launch the relevant smarforms for each of the payment instruments. you can use a field such as 'short key for House Bank'(reguh-HBKID) to select whether the payment method is 'NBPC' cheque or Payorder 'NBPP' [OR] you can use the 'Payment Method for This Payment' field(reguh-RZAWE) to check for the payment method 'C'(For Cheque) and 'E'(For Payorder).

Figure 01(A) : Attaching Print
Program in FBZP 'paymnt
methods in country'

Figure 01(B) : Position button
country code to seek out
payment methods

Figure 01(C) : Select the Payment
Method Row and click details button in
ApplicationToolbar

Figure 01(D) : Attaching Print
Program in FBZP and Click
Save button to assign

Sample Source Code:

  IF reguh-RZAWE EQ 'C'."A - Load Smartform for a Cheque [Payment Method = C(Cheque)]

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname = 'ZFJ_FI_VENDOR_CHEQUE'
      IMPORTING
        fm_name  = fname.

    CALL FUNCTION fname
      EXPORTING
        header_data = header_data"Header Data
      TABLES
        item_data   = item_data."Item Data

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

elseIF reguh-RZAWE EQ 'E'."B - Load Smartform for a Payorder [Payment Method = E(Payorder)]

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname = 'ZFJ_FI_VENDOR_PAYORDER'
      IMPORTING
        fm_name  = fname.

    CALL FUNCTION fname
      EXPORTING
        header_data = header_data
      TABLES
        item_data   = item_data.

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

  ENDIF.

Testing the Final Cheque or Payorder:

In order to test the newly attached replica of Payment Instrument Print program,you have the following 2 ways:

(A) At the Time of posting the document at runtime using transaction F-58:

> When you post a document via the F-58 transaction,you will be prompted to print the payment instrument then and there. In case you have skipped that step,you can use the second method to print it.

(B)Using the Transaction FBZ5 for printing Payment Instruments based on already posted documents,incase the user did not print them while posting them:

> You can print Already posted documents in Transaction FBZ5(Print form for Payment Document). You need to provide in details such as document number,company code,Fiscal year,payment method e.t.c. Just make sure that you have checked the 'Print Immediately' checkbox. Now go the following menu path:

                          Check > Print > Old Check

This will trigger you custom program and select the smartform based on the selection provided in the Payment Method field. You can even set a breakpoint in your custom program to check whether its working or not. You can then print the payment instrument like cheque or payorder,or seek out a Print Preview of the smartform.

Figure 02(A) : Checking Vendor
Cheque(FBZ5)

Figure 02(B) : Checking Vendor
Payorder(FBZ5)

[Tip]:You can seek out all documents already posted by looking into a Transparent table named 'PAYR' (Payment Medium File). Its also populated as a structure when the Standard Print program or your custom replica of it is invoked. Details from this table can be used for printing these payment instruments in the FBZ5 Transaction.


[B - SAP HR(Human Resources)]:

[B-02] - Creating Generic Checks for Standard HCM Infotypes(Human Resources)(Transactions = PA30,PB30,PA40,PB40)

Issue:

> How do we Add a custom enhancement in the form of Checks for an existing Standard Infotype in SAP HCM?

Solution:

> A Generic way to Create Enhancements in PA30 and PB30 based infotypes is to make use of an exit named 'PBAS0001'[PA: Pers.Admin./Recruitment: Default values and checks]. This can be opened up in  transaction 'SMOD'[SAP Enhancements]. You will find two function module exits with the following names:

> EXIT_SAPFP50M_001[Customer Default Values for Personnel Administration and Rec]

> EXIT_SAPFP50M_002[Customer Checks for Personnel Administration and Recruitment]

Figure B-02(A) : Standard exit in SMOD

Figure B-02(B) : Standard exit in SMODFigure B-02(C) : Function Module Exits

 

We will make used of the second function module exit for checks in Standard Infotypes  'EXIT_SAPFP50M_002'.

You can deploy the exit by creating an Enhancement Project via the Transaction 'CMOD'[Project Management of SAP Enhancements] in the customer namespace. Give it a Short Text Description.

Next Click the 'Enhancement assignments' and provide the Enhancement name 'PBAS0001' to assign the exit to our Enhancement Project. Now click the 'Components' button to find the two function module exits associated with enhancement PBAS0001. Double click the check exit function module named 'EXIT_SAPFP50M_002'. You will find an Include named 'ZXPADU02'. Double click it,it will prompt you to create the custom include with a transport request number. This is the point where you can write in the code for the given infotype using certain structures that are readily available to you within the include as Importing Parameters.

Figure B-02(2A) : Exit Project CMODFigure B-02(2B) : Enhancement Assignment CMODFigure B-02(2C) : Enhancement Components CMOD

 

These are the structures we will use from the Interface for targeting specific Infotypes,where the checks are to be Implemented.

(01)INNNN[Current Infotype Record]

This structure is populated at runtime and contains common information specific to Infotypes such as:

'PERNR(Employee Number)','INFTY'(Infotype Number),'SUBTY(Subtype Number),'ENDDA(End Date)','BEGDA'(Start Date).

This structure can be used for targeting specific Infotypes and subtypes.

(02)IPSYST[System Fields for HR Infotypes (PA/Recruitment)]:

This structure is used for screen specific Operations. One specific field that is quite useful is:

'IOPER'(Infotype Operation). Since Infotypes in HR are based single screen maintenance i.e. they don't have different transactions for Creation,deletion and display rather all of these operations could be performed from a single transaction. Some of the Possible values of the IOPER field include operations such as the following:

(a)'INS' = Create a New Entry

(b)'COP' = Copy an Existing entry

(c)'MOD' = Changing an Existing Entry

(d)'DEL' = When Deleting an Existing Entry

Extracting data entered by the user from the gjven Infotype at Runtime:

After providing in the checks,next we need to establish the data entered in by the user in the given infotype via an interface like mechanism. To get the Infotype data being entered,we use the static class method named 'CL_HR_PNNNN_TYPE_CAST=>PRELP_TO_PNNNN'. This is a downcast function that converts the exported structure to the infotype specific structure based on the INNNN Structure mentioned above. Here is a code snippet to use it.

Sample Source Code:     

CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PRELP_TO_PNNNN

        EXPORTING

          PRELP = INNNN

        IMPORTING

          PNNNN = I2006.

Here INNNN structure is provided in the user exit as part of the interface. The PNNNN structure is the infotype for which you wan't to extract data from. It can be declared as follows:

e.g:DATA: I2006 TYPE P2006.

 

Updating or Modifying data entered by the user from the gjven Infotype at Runtime:

You can assign multiple new values to existing infotype data entered by the user. This is especially true for calculations like adding an increment in basic pay based on a given formula e.t.c. To set or modify the Infotype data being entered,we use the static class method named 'CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP'. Here is a code snippet to use it:

Sample Source Code:

PNNNN = I0045."Value assignment to the Infotype data already entered in by the user at runtime

      MOVE 'XX' TO I0045-VDSK1."new value changes assigned

CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP"This method is used for changing existing values in Infotype 0045

        EXPORTING

          PNNNN = I0045

        IMPORTING

          PRELP = INNNN.

 


[Smartforms]:

[01] - Temporarily Disabling an Element of a Smartform

Figure 01(A) : Smartform before
disabling the Text node

Figure 01(B) : Text Node
to be Disabled

Figure 01(C) : Setting up Unequality
condition in the condition Tab

Figure 01(D) : Final Smartform
with the Text Node Disabled

Issue:

> How to disable an element in a Smartform?

Solution:

> There are many times when you want to temporarily disable a smartform element such as a Text Field,A Window,a Template,without deleting it. There is no such options within the Smartform tooling.
> This can easily be achieved by using the conditions tab found on most elements in the Smartforms editor.
> You just need to assign a true condition as not equal to achieve this.
e,g: 1 = 1(true),so write in:
    1 ≠ 1
to disable lets say a Text node.

This mechanism is quite usefull when printing smartforms on pre-printed stationary,where you can disable place holder texts and other elements,as they would already be printed on the pre-printed stationary.

[02] - Correcting in correct formatting of Amounts like commas replaced by dots and vice versa in a smartform

Figure 02(A) : Amount with wrong
formatting in a smartform

Figure 02(B) : Setting up Decimal
notation in User Profile

Figure 02(C) : Path for Setting up
Decimal notation globally in IMG Guide

Figure 02(D) : Setting the Decimal
notation format for a country code

Figure 02(E) : Customizing request
prompted when setting is saved

Figure 02(F) : Finally Amount with
corrected decimal notation

Issue:

> Why is an amount in a smartform showing dots in place of commas and vice versa,and how do i correct it?

Solution:

> Sometimes when you are working with amounts,you get the amounts formatted in a wrong way like commas replaced by decimals and vice versa.(see Figure 02(A))

> This issue can easily be resolved by going to the user profile and setting up decimal notation in the 'Defaults' tab. You can reach user profile by going to the menu path:
    System > User Profile > Own Data

   (see Figure 02(B))

> If still it does not show amount in proper amount format as set in the user profile,you will need to set up a setting in IMG reference guide,as that could eventually resolve the issue.
> To set it up,go to the following menu path in SPRO:
    SAP Netweaver > General Settings > Set Countries > Specify Countries in mySAP Systems(CRM,SRM,SCM,...)

> Now select your country code and double click it to get to the settings page for the country code. Just go the bottom of the Screen with a label of 'Date Format and Decimal Point'. There you will find a field named 'Dec.pt.format'. From the drop down select the second value,and click the save button. You will be asked for a Customizing Request,which would need to be transported to Production as well for this work there as well.(see Figure(s) 02(C),02(D),02(E))

> Re-run the smartform and voila the amount will be shown with the correct formatting.(see Figure 02(F))

[03] - Displaying a Smartform as a list Report

Figure 03(A) : Smartform Preview

Figure 03(B) : Smartform previewed
                         as an ALV List Report

Issue:

> How can i display a smartform as a list Report

Solution:

> You can display the output of a smartform as a list report by previewing it and then typing in 'SLIS' in the command field to display it as a list report.
> use the back button to get back to the smartform view.

 

[04] - Displaying a Smartform as a PDF

Figure 04(A) : Smartform Preview

Figure 04(B) : Smartform previewed in a pop-up widow as a PDF

  


Issue:

> How can i display a smartform as a PDF and download it as well without using an utility or ABAP function?

Solution:

> You can display the output of a smartform as a PDF file by previewing it and then typing in 'PDF!' in the command field to display it as a PDF report. This will give you a pop-up with the PDF file,you can download it from there.

 

[05] - Fixing an error of RAISE_EXCEPTION when a smartform has two or more Pages:

Figure 04(A) : Raise_Exception Error when running a smartform

Issue:

> How fix an error of raise_exception when calling a smartform?

Solution:

When ever you get an error of 'RAISE_EXCEPTION',terminated program 'SAPLSTXBC',with the following details[As checked in dump analysis[T-code = ST22]:

 "RAISE_EXCEPTION"

 "SAPLSTXBC" bzw. LSTXBCU19

 "SSFCOMP_GENERATE_SMART_FORM"

 

That means that you have two or more pages in a smartform and the width of their main windows are not same. Make the width of each main window for each of the pages,in order to fix this error. In case the if you change the width and it is going out of the page,adjust the main window so that it can be matched with the other page's main window when increasing the width. 

 

[06] - How to Disable MS Word Editor while editing text module in smartforms:

Figure 06(A) : Program for disabling MS Word as an

                          editor in Smartforms and SAP Script

Issue:

>  How can we Disable MS Word editor while editing text module in smartforms?

Solution:

> In order to disable the Word editor while editing smartforms,run the following program in SE38:

    'RSCPSETEDITOR'

>  Now uncheck the 'Smart Forms' checkbox and click the 'Activate button'. This will disable MS Word as an editor for

 editing text module in smartforms.

> This could be done previously through the i18n(Internationalization) tcode,using the following menu path:

    I18N Menu > I18N Customizing > MS Word as Editor

for newer systems use the editor program mentioned above.




[Classic ALV(ABAP List Viewer)]:

[01] - How to Set Icons and a Tooltip In An ALV Report

Figure 01(A) : RSTXICON - Selection Screen

Figure 01(B) : RSTXICON - Output with

Icon Codes

 

Figure 02 : Final ALV Output

with Icons and Tooltips

 

 

Issue:

> How to add an icon and a Tooltip to a classic ALV report using 'REUSE_ALV_GRID_DISPLAY' function?

Solution:

> You can access the report named 'RSTXICON' to access all 2 character icon codes.e.g: '9S'.This is the 4th column named 'Code' in the given standard report.

> You will need to create a character field of length 40 or more(in case you also need to add tooltips),to assign an icon with code enclosed within '@' signs.

e.g:

    '@9S@'

> you can also add a tool tip to you ALV code using the following in the icon field:

    \Q Inbound iDOC

within the @ signs.

e.g:

    @9S\Q Inbound iDOC@

 

Sample Source Code:

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

*& Report  ZALV_IC

*&

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

*& Demonstrates the use of icons  and Tooltips in an ALV

*& Report

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

REPORT ZALV_IC.

type-pools: slis.

***type-pools:

***            col,

***            icon.

***            sym.

data: fieldcatalog type slis_t_fieldcat_alv with header line,

      gd_tab_group type slis_t_sp_group_alv,

      gd_layout    type slis_layout_alv,

      gd_repid     like sy-repid.

TYPES : BEGIN of ls_icon,

          "Icon

          icon type c length 40 ,"Icon

        END OF ls_icon.

DATA:

      it_icon type STANDARD TABLE OF ls_icon,

      wa_icon like line of it_icon.

START-OF-SELECTION.

wa_icon-icon = '@9S\QInbound iDOC@'.

APPEND wa_icon to it_icon.

clear wa_icon.

 

wa_icon-icon = '@AH@'.

APPEND wa_icon to it_icon.

clear wa_icon.

 

wa_icon-icon = '@9T\QOutbound iDOC@'.

APPEND wa_icon to it_icon.

clear wa_icon.

 

END-OF-SELECTION.

perform build_fieldcatalog.

perform display_alv_report.

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

*&      Form  build_fieldcatalog

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

*       text

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

form build_fieldcatalog.

  fieldcatalog-fieldname   = 'ICON'."Icon

  fieldcatalog-seltext_l   = 'Direction of iDOC - Icon' .

  fieldcatalog-tabname   = 'IT_IDOCMON'.

  append fieldcatalog to fieldcatalog.

  clear  fieldcatalog.

endform.                    " BUILD_FIELDCATALOG

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

*&      Form  DISPLAY_ALV_REPORT

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

*       Display report using ALV grid

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

form display_alv_report.

  gd_repid = sy-repid.

  gd_layout-colwidth_optimize = 'X'."For optimizing the Width of all Columns

*break abapdev .

  call function 'REUSE_ALV_GRID_DISPLAY'

       exporting

            i_callback_program      = gd_repid

            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM

 

            is_layout               = gd_layout

            it_fieldcat             = fieldcatalog[]

*            IT_EVENTS                = GT_XEVENTS

            i_save                  = 'X'

*            is_variant              = z_template

       tables

            t_outtab                = it_icon

       exceptions

            program_error           = 1

            others                  = 2.

  if sy-subrc <> 0.

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

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

  endif.

endform.                    " DISPLAY_ALV_REPORT

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

*&      Form  top-of-page

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

*       text

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

form top-of-page.

*ALV Header declarations

  data: t_header type slis_t_listheader,

        wa_header type slis_listheader,

        t_line like wa_header-info,

        ld_lines type i,

        ld_linesc(10) type c,

        dates(50) type c.

  wa_header-typ  = 'H'.

  wa_header-info = 'ALV'.

  append wa_header to t_header.

  clear wa_header.

 

  wa_header-typ  = 'S'.

  wa_header-info = 'Icons in an ALV' .

  append wa_header to t_header.

  clear wa_header.

 

  call function 'REUSE_ALV_COMMENTARY_WRITE'

    exporting

      it_list_commentary = t_header.

 

endform.                    "top-of-page


[02] - Functions And Classes For Creating ALV Reports[Q&A]

> There are many ways in which you can create ALV reports. Some are based on Function Modules and Some are based on Classes:

(a)REUSE_ALV_GRID_DISPLAY(Function Module)

(b)REUSE_ALV_GRID_DISPLAY_LVC(Function Module)

(c)CL_GUI_ALV_GRID(Class)

(d)CL_SALV_TABLE(Class)

 

 


[BDC(Business Communication Data]:

[01] - How to export a BDC recording from one client to another:

Figure 01(A) : Editing Or Displaying An Existing

BDC recordingViaT-code SHDB 

Figure 01(B) : When In Editing Or Display Mode -

Use menu Path = Recording > Export

Figure 01(C) : Dialog Box For Saving The

BDC Recording as a File

Figure 01(D) : Now In The Target Client Create a

Recording With the Same Name

Figure 01(E) : Create a Recording Pop-Up shows

Figure 01(F) : Provide Initial Parameters and

try to save it

Figure 01(G) : In Case you can't save it, go back  this

will Create the recording

Figure 01(H) : If you see the Macro like code for the recording Just Save it

Figure 01(I) : Once Recording is Saved

We need to Import the Saved Recording

Figure 01(J) : A pop-up will Show for Importing the Recording File

Figure 01(K) : A pop-up might show up Regarding Security Warning

Figure 01(L) : Once Done the existing

Recording will be replaced with the

existing one

Issue:

> How to export a BDC recording from one client to another?.

Solution:

> There are times when you require a bdc recording for creation of an upload or a posting program.

> In case if the functional consultant has created a BDC recording for you in the test client which has all master data along with configuration,but not on the client where you need to develop your own program based on this recording.

> For such cases, you can export a bdc recording from one client to another e.g: from test client to development client.

> In this tip,we'll go through the steps required for exporting the BDC recording to a file from the Source Client to the Importing of this recording in the Target Client.

Steps Required on the Source Client:

(01)Select the BDC recording that needs to be exported ?to an external file.

(02a)Go to the edit or display mode of he BDC recording in order to export it. Use the following menu path:

    Recording > Export

(02b)You will now be presented with an export dialog box for saving the BDC recording file. Give the file a name and then click the 'save' button to save the BDC recording so that it could be later on imported on the Target client.

Steps Required on the Target Client:

(03a)Create a new dummy or placeholder recording with the same name as the one exported from the Source Client

in the target client.

(03b)Provide the name in the pop-up dialog box along with the T-code for which you wan't to create the recording.

(03c)Provide in the basic parametersfor the recording and try to save it.

(03d)In case their is no data for the provide parameters and its not saving, just press the back button or press the F3 key

to exit,so that the recording is created. A Pop-up will also be shown for exiting out of the recording.

(03e)Once you see the Macro Recording like code,click the save button to save the recording on the Target Client.

 

(04a)Now to import the already exported bdc recording file,use the following menu path:

    Recording > Import

and provide the bdc recording file saved earlier.

(04b)You might get a security dialog box,just click the 'Allow' button to provide access to the file.

(04c)Once imported,the newly created placeholder recording will be replaced by the external BDC recording file.

This method of downloading and importing a BDC recording is quite useful when you have to two clients on a project : (01)Development client (02)Test client where

master data is there for testing and when the Functional Consultant has made a BDC recording on the test client.

 


 

[ABAP]:

[01] - Adding Leading Zeros to character based number based on its Length

Figure 01(A) : Adding Leading
Zeros - Final Output

Issue:

> How to add leading zeros to a character based number based on its length?

Solution:

> There is a construct in ABAP named 'unpack',which will add leading zeroes to a character based number based on its actual length. This is especially useful of there is a particular format for data files that are to be exchanged with legacy systems.

Sample Source Code:

*&---------------------------------------------------------------------*
*& Report  ZCONCATENATE_TESTER
*&
*&---------------------------------------------------------------------*

REPORT  ZCONCATENATE_TESTER NO STANDARD PAGE HEADING.

DATA:
      og_cnic type c length 10 value '534212333',
      lz_cnic type c length 12,"For Copying a variable to length of 12 instead of the original 8 length
      len_original type i,
      len_newvar type i
      .

START-OF-SELECTION.

**lz_cnic = og_cnic.
unpack og_cnic to lz_cnic.
len_original = strlen( og_cnic ).
len_newvar = strlen( lz_cnic ).

  write:/ 'Actual Value',og_cnic,' Length: ',len_original.
  write :/'Final Value with Leading Zero''s',lz_cnic,' Length: ',len_newvar.

[02] - For Extracting the Texts of Fixed Values in Domains

Figure 02(A) : Selection Screen

Figure 02(B) : Output of Fixed
Value Range

Figure 02(C) : Output of Fixed
Value Text



Issue:

> How can we extract the Fixed value Texts for the given domains?

Solution:

> Fixed value Domain Texts can be extracted via the function module 'DD_DOMA_GET'. You pass in the Domain Name from the Data Dictionary and it will extract the entire contents of the fixed value as well as its text in an internal table which could be used for showing its texts for reporting purposes.

Sample Source Code:

*&---------------------------------------------------------------------*
*& Report  ZDOMAIN_FXVAL_READ
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZDOMAIN_FXVAL_READ NO STANDARD PAGE HEADING.
SELECTION-SCREEN begin of BLOCK dom.
  PARAMETERS :
              pa_domn type DD01L-DOMNAME.
SELECTION-SCREEN end of BLOCK dom.

    DATA:
          dd07v_tab_a  type STANDARD TABLE OF DD07V WITH HEADER LINE,"For Domain Fixed Values
          dd07v_tab_n  type STANDARD TABLE OF DD07V WITH HEADER LINE,"For Domain Fixed Values
          DCDOMAGET type DCDOMAGET."Structure

    DCDOMAGET-DOMA = 'M'.
    DCDOMAGET-DOHD = 'M'.
    DCDOMAGET-DOFV = 'M'.

    CALL FUNCTION 'DD_DOMA_GET'
     EXPORTING
       DOMAIN_NAME         = pa_domn
       GET_STATE          = DCDOMAGET
***       GET_STATE          = 'M '
       LANGU               = SY-LANGU
       PRID                = 0
       WITHTEXT            = 'X'
*     IMPORTING
*       DD01V_WA_A          =
*       DD01V_WA_N          =
*       GOT_STATE           =
      TABLES
        dd07v_tab_a         = dd07v_tab_a
        dd07v_tab_n         = dd07v_tab_n
     EXCEPTIONS
       ILLEGAL_VALUE       = 1
       OP_FAILURE          = 2
       OTHERS              = 3
              .
    IF sy-subrc <> 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

LOOP AT dd07v_tab_a.
  Write : / 'Fixed Value Low= ',dd07v_tab_a-DOMVALUE_L COLOR 1 CENTERED,'Fixed Value High= ',dd07v_tab_a-DOMVALUE_H COLOR 1 CENTERED, 'Fixed Value Text= ',dd07v_tab_a-DDTEXT COLOR 1 CENTERED.
ENDLOOP.

 


[ABAP Objects]:

[01] - How to pass an Internal Table as an export parameter in Method of a class:

Figure 01_A: Global Table Type inSE11Figure 01_B: Choose Table TypeFigure 01_C: Passing the Dictionary structure as Line Type
Figure 01_D: Method for assigning Export Parameter in a Global ClassFigure 01_E: Export Parameter of type Table Type

 

Issue:

> Unable to pass an internal table as an export parameter in a method of a Global Class?

Solution:

  > You can create an export parameter of any dictionary type in a class method,But if you pass the content of internal

table to it,it would give a dump. Even if you open up the source code view of a class,you won't be able to use the

'standard table of' additions to an export parameter.

> To overcome this,create a global 'Table Type' from T-code 'SE11' and choose the radio button 'Data type'. When you

click the 'Create' button,you will be prompted with a Dialog Box,choose 'Table type'. In the 'Line Type' tab and in the

'Line Type' field Add the reference to your structure or any other dictionary type,to create a global internal table.

> Next declare an export parameter in the class's method by clicking the 'parameters' button in t-code 'SE24'.

> Provide a name for the parameter in our case 'IT_TRAINING'. In the type field choose 'Exporting'. In the 'Typing

Method' field choose 'Type' and in the 'Associate Type' field,provide the Global 'Table Type' created earlier.


 

 

 




 

 

 

Useful Information

These are a list of tips and tricks that i have experienced on different Projects. These include workarounds for certain limitations, Tips and troubleshooting solutions for overcoming certain problems found in a given project. Each of these solutions would be categorized according to their usage.