Sunday, April 18, 2010

EBP Shoping Cart: How to get PO number in EBP

Use BBP_PD_OBJREL_READ_VIA_REF.

Guaranteed found.

reference:
http://3i-consulting.com/wug/html/File_SAP-WUG_LOG0302B/00000127.htm

Thursday, March 4, 2010

HOW TO FIND TABLE BASED ON STRUCTURE GIVEN

table D010TAB consists the information about tables used by a program.

table DD03L consists the information about table, fieldname and Data
element.

Thursday, February 4, 2010

SMARTFORM: Convert Smartform to PDF format


Source: SAP Community
Summary: Converting the smartform to PDF is process of 3 simple steps.
  • Calling the Smart form, then it returns the OTF data in Return.
  • Converting the OTF data into required format using the Function Module CONVERT_OTF_2_PDF.
  • Download the File 

    *&---------------------------------------------------------------------*
    *& Report  ZTEST_NREDDY_PDF
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    REPORT  ZTEST_NREDDY_PDF.
    * Internal table declaration
    DATA: it_otf      TYPE STANDARD TABLE OF itcoo,
          it_docs     TYPE STANDARD TABLE OF docs,
          it_lines    TYPE STANDARD TABLE OF tline.
    * Declaration of local variables.
    DATA:
          st_job_output_info       TYPE ssfcrescl,
          st_document_output_info  TYPE ssfcrespd,
          st_job_output_options    TYPE ssfcresop,
          st_output_options        TYPE ssfcompop,
          st_control_parameters    TYPE ssfctrlop,
          v_len_in                 TYPE so_obj_len,
          v_language               TYPE sflangu VALUE 'E',
          v_e_devtype              TYPE rspoptype,
          v_bin_filesize           TYPE i,
          v_name                   TYPE string,
          v_path                   TYPE string,
          v_fullpath               TYPE string,
          v_filter                 TYPE string,
          v_uact                   TYPE i,
          v_guiobj                 TYPE REF TO cl_gui_frontend_services,
          v_filename               TYPE string,
          v_fm_name                TYPE rs38l_fnam.
    CONSTANTS c_formname           TYPE tdsfname VALUE 'ZTEST'.
    CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
      EXPORTING
        i_language          = v_language
        i_application       = 'SAPDEFAULT'
      IMPORTING
        e_devtype           = v_e_devtype.
    st_output_options-tdprinter = v_e_devtype.
    st_control_parameters-no_dialog = 'X'.
    st_control_parameters-getotf = 'X'.
    *.................GET SMARTFORM FUNCTION MODULE NAME.................*
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname = c_formname
      IMPORTING
        fm_name  = v_fm_name
      EXCEPTIONS
        no_form  = 1
       no_function_module = 2   
        OTHERS   = 3.
    *...........................CALL SMARTFORM............................*
    CALL FUNCTION v_fm_name
      EXPORTING
        control_parameters = st_control_parameters
        output_options     = st_output_options
      IMPORTING
        document_output_info  = st_document_output_info
        job_output_info       = st_job_output_info
        job_output_options    = st_job_output_options
      EXCEPTIONS
        formatting_error = 1
        internal_error   = 2
        send_error       = 3
        user_canceled    = 4
        OTHERS           = 5.
    *.........................CONVERT TO OTF TO PDF.......................*
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
        IMPORTING
          bin_filesize   = v_bin_filesize
        TABLES
          otf            = st_job_output_info-otfdata
          doctab_archive = it_docs
          lines          = it_lines
        EXCEPTIONS
          err_conv_not_possible  = 1
          err_otf_mc_noendmarker = 2
          OTHERS                            = 3.
     *........................GET THE FILE NAME TO STORE....................*
      CONCATENATE 'smrt' '.pdf' INTO v_name.
      CREATE OBJECT v_guiobj.
      CALL METHOD v_guiobj->file_save_dialog
        EXPORTING
          default_extension  = 'pdf'
          default_file_name  = v_name
          file_filter        = v_filter
        CHANGING
          filename           = v_name
          path               = v_path
          fullpath           = v_fullpath
          user_action        = v_uact.
      IF v_uact = v_guiobj->action_cancel.
        EXIT.
      ENDIF.
    *..................................DOWNLOAD AS FILE....................*
    
      MOVE v_fullpath TO v_filename.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          bin_filesize     = v_bin_filesize
          filename         = v_filename
          filetype         = 'BIN'
        TABLES
          data_tab         = it_lines
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
    *------------------------------------------------------------------------
    Or other option
    How to convert smartform output into pdf?
    There is a way to download smartform in PDF format.
    Please do the following:  
    1. Print the smartform to the spool.  
    2. Note the spool number.  
    3. Download a PDF file (Acrobat Reader) version of the spool by running Program RSTXPDFT4 and entering the  
    noted spool number.
    or use this program:
    
    &---------------------------------------------------------------------
    *& Report ZPDF_DNLD_TEST2 *
    *& *
    &---------------------------------------------------------------------
    *& DEVK904540 *
    *& *
    &---------------------------------------------------------------------
    
    REPORT ZPDF_DNLD_TEST2 .
    
    data: i_otf LIKE itcoo OCCURS 100 WITH HEADER LINE,
    i_pdf LIKE tline OCCURS 100 WITH HEADER LINE.
    
    data: op_option type SSFCTRLOP,
    job_output type SSFCRESCL.
    
    op_option-getotf = 'X'.
    
    CALL FUNCTION '/1BCDWB/SF00000005'
    EXPORTING
    
    ARCHIVE_INDEX = 
    ARCHIVE_INDEX_TAB = 
    ARCHIVE_PARAMETERS = 
    CONTROL_PARAMETERS = op_option
    
    MAIL_APPL_OBJ = 
    MAIL_RECIPIENT = 
    MAIL_SENDER = 
    OUTPUT_OPTIONS = 
    USER_SETTINGS = 'X' 
    itab1 = itab1 
    IMPORTING
    
    DOCUMENT_OUTPUT_INFO = 
    JOB_OUTPUT_INFO = job_output
    
    JOB_OUTPUT_OPTIONS = 
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5
    .
    IF sy-subrc 0.
    
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
    ENDIF.
    
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    
    MAX_LINEWIDTH = 132 
    ARCHIVE_INDEX = ' ' 
    COPYNUMBER = 0 
    ASCII_BIDI_VIS2LOG = ' ' 
    PDF_DELETE_OTFTAB = ' ' 
    IMPORTING 
    BIN_FILESIZE = 
    BIN_FILE = 
    TABLES
    otf = job_output-otfdata
    lines = i_pdf
    
    EXCEPTIONS 
    ERR_MAX_LINEWIDTH = 1 
    ERR_FORMAT = 2 
    ERR_CONV_NOT_POSSIBLE = 3 
    ERR_BAD_OTF = 4 
    OTHERS = 5 
    .
    IF sy-subrc 0.
    
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
    ENDIF.
    
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    
    BIN_FILESIZE = 
    filename = 'c:\test_pdf_sf.pdf'
    FILETYPE = 'BIN'
    
    tables
    data_tab = i_pdf
    
    FIELDNAMES = 
    EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH = 2
    GUI_REFUSE_FILETRANSFER = 3
    INVALID_TYPE = 4
    NO_AUTHORITY = 5
    UNKNOWN_ERROR = 6
    HEADER_NOT_ALLOWED = 7
    SEPARATOR_NOT_ALLOWED = 8
    FILESIZE_NOT_ALLOWED = 9
    HEADER_TOO_LONG = 10
    DP_ERROR_CREATE = 11
    DP_ERROR_SEND = 12
    DP_ERROR_WRITE = 13
    UNKNOWN_DP_ERROR = 14
    ACCESS_DENIED = 15
    DP_OUT_OF_MEMORY = 16
    DISK_FULL = 17
    DP_TIMEOUT = 18
    FILE_NOT_FOUND = 19
    DATAPROVIDER_EXCEPTION = 20
    CONTROL_FLUSH_ERROR = 21
    OTHERS = 22
    .
    IF sy-subrc 0.
    
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
    ENDIF.

Tuesday, February 2, 2010

SMARTFORMS: HOW TO DEBUG

Open smartforms, find environement - function module.Copy it.











Open se37,  paste the func name and Display the function.
Click on GOTO on the menu bar. Click on Main program.














You canm see the includes. click on the last include i.e F01.


















Play around inside this FM.

Happy debugging.

Monday, November 23, 2009

Smartforms: system fields eg: page no

System fields of Smart Forms

&SFSY-DATE&
Displays the date. You determine the display format in the user master record.

&SFSY-TIME&
Displays the time of day in the form HH:MM:SS.

&SFSY-PAGE&
Inserts the number of the current print page into the text. You determine the format of the page number (for example, Arabic, numeric) in the page node.

&SFSY-FORMPAGES&
Displays the total number of pages for the currently processed form. This allows you to include texts such as'Page x of y' into your output.

&SFSY-JOBPAGES&
Contains the total page number of all forms in the currently processed print request.

&SFSY-WINDOWNAME&
Contains the name of the current window (string in the Window field)

&SFSY-PAGENAME&
Contains the name of the current page (string in the Page field)

&SFSY-PAGEBREAK&
Is set to 'X' after a page break (either automatic [Page 7] or command-controlled [Page 46])

&SFSY-MAINEND&
Is set as soon as processing of the main window on the current page ends

&SFSY-EXCEPTION&
Contains the name of the raised exception. You must trigger your own exceptions, which you defined in the form interface, using the user_exception macro (syntax: user_exception ).

Wednesday, October 28, 2009

Upload CSV File

REPORT zupload_csv_file.

TYPES: BEGIN OF ttab,
rec(1000) TYPE c,
END OF ttab.

TYPES: BEGIN OF tdat,
fld1(10) TYPE c,
fld2(10) TYPE c,
fld3(10) TYPE c,
END OF tdat.

DATA: itab TYPE TABLE OF ttab WITH HEADER LINE.
DATA: idat TYPE TABLE OF tdat WITH HEADER LINE.

DATA: file_str TYPE string.

PARAMETERS: p_file TYPE localfile.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = p_file.

START-OF-SELECTION.

file_str = p_file.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_str
TABLES
data_tab = itab
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.


LOOP AT itab.
CLEAR idat.
SPLIT itab-rec AT ',' INTO idat-fld1
idat-fld2
idat-fld3.
APPEND idat.

ENDLOOP.


LOOP AT idat.
WRITE:/ idat-fld1, idat-fld2, idat-fld3.
ENDLOOP.

Selection Screen

Loop at screen
modify screen.
endloop.

To modify screen outlook.

http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbab6f35c111d1829f0000e829fbfe/content.htm

eg:

REPORT demo_dynpro_modify_simple.

DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.

DATA flag(1) TYPE c.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
LOOP AT SCREEN.
IF screen-group1 = 'MOD'.
IF flag = ' '.
screen-input = '0'.
ELSEIF flag = 'X'.
screen-input = '1'.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDMODULE.

MODULE cancel.
LEAVE PROGRAM.
ENDMODULE.

MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'TOGGLE'.
IF flag = ' '.
flag = 'X'.
ELSEIF flag = 'X'.
flag = ' '.
ENDIF.
ENDCASE.
ENDMODULE.

Messages SE91 msg class

Refer:
1. http://abaplovers.blogspot.com/2008/02/displaying-messages-in-abap.html
2. http://www.abapprogramming.net/2009/02/syntax-for-message.html

eg:
MESSAGE E010 WITH 'Example' SY-UNAME.

1. MESSAGE xnnn.
2. MESSAGE ID id TYPE mtype NUMBER n.
3. MESSAGE xnnn(mid).

There are six kinds of message type:
A (Abend)
Termination
E (Error)
Error
I (Info)
Information
S (Status)
Status message
W (Warning)
Warning
X (Exit)
Termination with short dump
See the syntax shown below for displaying a message in your programs.

MESSAGE ID id TYPE mtype NUMBER n.

ID
message class in our case ZEXERCISE1 or ZEXERCISE2
TYPE
message type (A,E,I,S,W,X)
NUMBER
message number
Example

MESSAGE ID 'ZEXERCISE' TYPE 'S' NUMBER '000'.

HR:table HRP1001 deletion

Deletion of table hrp1001 must be done fo r both relations p-q and q-p.
Eg:

select * from hrp1001 into table itab_1001a
where otype = 'P'
and plvar = '01'
and rsign = 'A'
and relat = '032'
and istat = '1'
and begda = p_begda
and endda = p_endda
and infty = '1001'
and subty = 'A032'
and aedtm in s_aedtm
and uname = p_uname
and sclas = 'Q'.

select * from hrp1001 into table itab_1001b
where otype = 'Q'
and plvar = '01'
and rsign = 'B'
and relat = '032'
and istat = '1'
and begda = p_begda
and endda = p_endda
and infty = '1001'
and subty = 'B032'
and aedtm in s_aedtm
and uname = p_uname
and sclas = 'P'.

Tuesday, September 8, 2009

HR: T-CODE PE03 for config

Can use the following FM to retrive info from config set in tcode pe03.
Eg:
FORM get_join_petr_date.
DATA: type(3),
info(3),
new(3) VALUE 'NEW',
flg_index type n. " add nan/rohaizad 100909

* The pe03 config has been set to use struc zpme0.

LOOP AT p0000.
MOVE-CORRESPONDING p0000 TO zpme0.
PERFORM re549d USING '$TYPE' info type subrc.
CHECK type EQ new.

Reference on PE03:
http://88.191.95.122/index.php/dev/109-general-concepts/141-features.html

reference on FM re549d:
http://www.sdn.sap.com/irj/scn/index;jsessionid=(J2EE3417200)ID2054469750DB21140978652675665956End?rid=/library/uuid/80b18e32-003b-2c10-68a6-dce4b0396128&overridelayout=true