Rabu, 19 September 2012

How To Create HOTSPOT In ABAP



In this tutorial you will learn how to create HOTSPOT using ABAP, this HOTSPOT will allow you to click on the text and then pass the value to be used as a parameter for your query.
Here’s the ABAP Sample code to create the HOTSPOT. In this example, we will retrieve the customer name and address.

ZREPORT_HOTSPOT.

tables:
vbak,
kna1.
START-OF-SELECTION.
select single kunnr into (vbak-kunnr) from VBAK.
write :/ vbak-kunnr HOTSPOT on.
*“Event when user click on the text on the
*“Screen
AT LINE-SELECTION.
select single land1 name1 into
(kna1-land1, kna1-name1) from kna1
where kunnr = vbak-kunnr.
write:/ kna1-land1, kna1-name1.

Defining Print Parameters In SAP



SAP is using certain print parameters for its print outs. For example to print out Billing, Sales Document, there are parameters to maintain such as the program’s name, the report’s name (SmartForms or SAPscript), The output message type, etc.

For example in VA03, SAP is maintaining several output types to print each transaction, e.g. Billing, Sales, Debit Note, etc. 





Now to see what parameters maintained for each output type (Printing Parameters), you can use TCODE V/30.
1. Execute TCODE V/30.
2. Now you can see the output type list for each transaction, click on the “Position” button to search an output type.
 
 3. Enter the Output Type that you want to find and click OK or just press enter.


 4. Select the output type and double click on the “Processing Routine” section.

  
5. On the next screen, you will see the print parameters for the selected output type. E.g. The ABAP program’s name, the SmartForms name, etc.


Senin, 17 September 2012

ABAP Read_Text Function Module Tutorial To Read Long Text



In today’s tutorial, I want to show you how to use the READ_TEXT function module to read SAP long text. Every text in SAP has its own ID and NAME, by passing these parameters into the READ_TEXT function, we can get all the text in the SAP long text object.

Here’s how to do it, for example we’ll be using long text from Sales Order.
1. Execute tcode VA02 and enter the Sales Order number.



2. Press enter to display the Sales Order data. Choose GoTo -> Header -> Texts



3. Double click the “Header Note” text and enter the long text in the text editor.
  

4. Click CTRL+S to save the Sales Order data.

5. Now that we need to get the “ID”, “NAME” and “OBJECT” of the text object to be used as the input parameters of READ_TEXT function module, to get this information, you can execute VA02 or VA03 and enter the Sales Order number again.
Choose GoTo -> Header -> Texts 

6. Now double click inside the long text editor.


7. Choose Goto -> Header.
 

8. On the next window screen, you will see all the parameters required for the READ_TEXT function. (Name, Language, ID, Object)



9. Now let’s get the text using ABAP, open your ABAP editor (SE38), copy this code below.
"A sample code to use READ_TEXT FM

  data:
        BEGIN OF header OCCURS 0,
          ld_txt1(163),
          ld_txt2(163),
          ld_txt3(163),
        END OF header.

  DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
        ID like THEAD-TDID,
        TNAME LIKE THEAD-TDNAME,
        TDOBJECT like THEAD-TDOBJECT.

        ID = '0001'.
        TNAME = '1820000009'.
        TDOBJECT = 'VBBK'.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      id       = id
      language = sy-langu
      name     =  TNAME
      object   = TDOBJECT
    TABLES
      lines    = li_lines.

  READ TABLE li_lines INDEX 1.
  IF sy-subrc = 0.
    header-ld_txt1 = li_lines-tdline.
  ENDIF.

  READ TABLE li_lines INDEX 2.
  IF sy-subrc = 0.
    header-ld_txt2 = li_lines-tdline.
  ENDIF.

  READ TABLE li_lines INDEX 3.
  IF sy-subrc = 0.
    header-ld_txt3 = li_lines-tdline.
  ENDIF.

  WRITE:/ header-ld_txt1.
  WRITE:/ header-ld_txt2.
  WRITE:/ header-ld_txt3.

10. Now execute the program (F8), you will see the long text from the header note text object.