Sunday, December 11, 2011

SIMPLE ALV REPORT

REPORT  ZSIMPLEALVREPORT.


type-pools : slis.
data:   it_fieldcat type slis_t_fieldcat_alv,
        lt_top_of_page 
type slis_t_listheader,
        ls_layout      
type slis_layout_alv,
        gt_events      
type slis_t_event.

data : begin of t_lips occurs 0,
          vbeln 
type lips-vbeln ,
          brgew 
type lips-brgew,
       
end of t_lips.

data : begin of t_vttp occurs 0,
          vbeln 
type vttp-vbeln,
          tknum 
type vttp-tknum,
       
end of t_vttp.

data : begin of t_vttp2 occurs 0,
          brgew 
type lips-brgew,
          tknum 
type vttp-tknum,
       
end of t_vttp2.

data :  wa_fieldcat like line of it_fieldcat.

parameters : so like lips-vgbel.


start-
of-selection.
*****data selection part***
  
perform data_selection.
******data display*****
  
perform data_display.
*

form data_selection .

select
  vbeln
  brgew
  
from lips into CORRESPONDING FIELDS OF TABLE t_lips
  
WHERE vgbel = so.

   
SELECT  vbeln
           tknum
    
from vttp into CORRESPONDING FIELDS OF TABLE t_vttp
    
for ALL ENTRIES IN t_lips[]
    
where vbeln = t_lips-vbeln.

Loop at t_lips.
  
read table t_vttp WITH key vbeln = t_lips-vbeln.
     t_vttp2-brgew = t_lips-brgew.
     t_vttp2-tknum = t_vttp-tknum.
  
APPEND t_vttp2.
  
endloop.

endform.                    " DATA_SELECTION


form data_display .

  
perform get_values.
  
perform grid_display.

endform.                    " DATA_DISPLAY


form get_values .

  wa_fieldcat-fieldname = 
'BRGEW'.
  wa_fieldcat-ref_tabname = 
'T_VTTP2'.
  wa_fieldcat-seltext_l = 
'GROSS WEIGHT'.
  wa_fieldcat-outputlen = 
20.
  wa_fieldcat-col_pos     = 
'1'.
  
append wa_fieldcat to it_fieldcat.
  
clear wa_fieldcat.



  wa_fieldcat-fieldname = 
'TKNUM'.
  wa_fieldcat-ref_tabname = 
'T_VTTP2'.
  wa_fieldcat-seltext_l = 
'SHIPMENT NO.'.
  wa_fieldcat-outputlen = 
20.
  wa_fieldcat-col_pos     = 
'2'.
  
append wa_fieldcat to it_fieldcat.
  
clear wa_fieldcat.



endform.                    " GET_VALUES

form grid_display .

  
call function 'REUSE_ALV_GRID_DISPLAY'

  
exporting
    i_callback_program                = sy-cprog
    is_layout                         = ls_layout
    it_fieldcat                       = it_fieldcat[]

   it_events                         = gt_events[]
   
tables
     t_outtab                          = t_vttp2[]
 
exceptions
  program_error                     = 
1
  
others                            = 2
           .
  
if sy-subrc <> 0.

  
endif.


endform.                   

Monday, September 26, 2011

Inserting multiple entries in a database table

REPORT INSERTMULTIPLEENTRIES.
* Work area
TABLES CUSTOMERS.
* Internal table for new entries
DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100
             WITH HEADER LINE.
* Filling the internal table
ALL_CUSTOMERS-ID            = '12345678'.
ALL_CUSTOMERS-NAME = 'Brown'.
APPEND ALL_CUSTOMERS.
ALL_CUSTOMERS-ID          = '11111111'.
ALL_CUSTOMERS-NAME = 'Green'.
APPEND ALL_CUSTOMERS.
ALL_CUSTOMERS-ID          = '12121212'.
ALL_CUSTOMERS-NAME = 'White'.
APPEND ALL_CUSTOMERS.
* Inserting the internal table
INSERT CUSTOMERS FROM TABLE ALL_CUSTOMERS.

Inserting single entries in a database table

REPORT INSERTSINGLEENTRIES.
* Work area
TABLES CUSTOMERS.
* Record used as alternative work area
DATA MY_CUSTOMER LIKE CUSTOMERS.
* Inserting one entry from the work area
CUSTOMERS-ID = '12345678'.
CUSTOMERS-NAME = 'Brown'.
INSERT CUSTOMERS.
IF SY-SUBRC <> 0.
 WRITE: / 'Entry already exists:', CUSTOMERS-ID.
ENDIF.
* Inserting one entry from the record
MY_CUSTOMER-ID = '11111111'.
MY_CUSTOMER-NAME = 'Green'.
INSERT INTO CUSTOMERS VALUES MY_CUSTOMER.
IF SY-SUBRC <> 0.
 WRITE: / 'Entry already exists:', MY_CUSTOMER-ID.
ENDIF.

Thursday, August 4, 2011

Pop up window to select month

CALL FUNCTION 'POPUP_TO_SELECT_MONTH'       

EXPORTING
actual_month = ld_spmon

IMPORTING
selected_month = ld_spmon
return_code = ld_returncode
EXCEPTIONS factory_calendar_not_found = 01
holiday_calendar_not_found = 02
month_not_found = 03.

pop up message yes / no in ABAP

REPORT zpopup_menu_yesno. 

DATA : ld_answer TYPE string.

CALL FUNCTION 'POPUP_CONTINUE_YES_NO'

EXPORTING

textline1 = 'POPUP MENU'
textline2 = 'Yes or No?!'
titel = 'Change Confirmation'

IMPORTING

answer = ld_answer.
IF ld_answer = 'J'.
WRITE : / 'Yes !'.
ELSE.
WRITE : / 'Oh, No !'.
ENDIF.

How to catch DUMP in ABAP

REPORT ZCATCHDUMPEXAMPLE.

PARAMETERS: p_file LIKE rlgrap-filename .
DATA: v_file TYPE string.
DATA: BEGIN OF itab OCCURS 0,
      name(23) TYPE  c,
      END OF itab.

DATA: errormessage TYPE char50.
v_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename            = v_file
    filetype            = 'ASC'
    has_field_separator = ' '
  TABLES
    data_tab            = itab.

RECEIVE RESULTS FROM FUNCTION 'GUI_UPLOAD'
 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 .

CASE sy-subrc.
  WHEN 0.
    errormessage     = 'Data Loaded'.
  WHEN 1.
    errormessage     = 'FILE_OPEN_ERROR'.
  WHEN 2.
    errormessage     = 'FILE_READ_ERROR'.
  WHEN 3.
    errormessage     = 'NO_BATCH'.
  WHEN 4.
    errormessage     = 'GUI_REFUSE_FILETRANSFER'.
  WHEN 5.
    errormessage     = 'INVALID_TYPE'.
  WHEN 6.
    errormessage     = 'NO_AUTHORITY'.
  WHEN 7.
    errormessage     = 'UNKNOWN_ERROR'.
  WHEN 8.
    errormessage     = 'BAD_DATA_FORMAT'.
  WHEN 9.
    errormessage     = 'HEADER_NOT_ALLOWED'.
  WHEN 10.
    errormessage     = 'SEPARATOR_NOT_ALLOWED'.
  WHEN 11.
    errormessage     = 'HEADER_TOO_LONG'.
  WHEN 12.
    errormessage     = 'UNKNOWN_DP_ERROR'.
  WHEN 13.
    errormessage     = 'ACCESS_DENIED'.
  WHEN 14.
    errormessage     = 'DP_OUT_OF_MEMORY'.
  WHEN 15.
    errormessage     = 'DISK_FULL'.
  WHEN 16.
    errormessage     = 'DP_TIMEOUT'.
  WHEN 17.
    errormessage     = 'OTHERS'.
ENDCASE.

MESSAGE e001(00) WITH errormessage .

Wednesday, August 3, 2011

An Example of a ListBox Program

REPORT ZLISTBOXPROGRAM.


TYPE-POOLS: VRM.

DATA: NAME  TYPE VRM_ID,
      LIST  TYPE VRM_VALUES,
      VALUE LIKE LINE OF LIST,
      c(20type c.

DATA:BEGIN OF itab OCCURS 0,
      kunnr like kna1-kunnr,
      name1 like kna1-name1,
     END OF itab.

DATA:BEGIN OF jtab OCCURS 0,
      kunnr like kna1-kunnr,
      land1 like kna1-land1,
     END OF jtab.

PARAMETERS: option(20AS LISTBOX VISIBLE LENGTH 20
                          default 'SELECT'.

AT SELECTION-SCREEN OUTPUT.

NAME = 'option'.

VALUE-KEY = '1'.
VALUE-TEXT = 'Company'.
APPEND VALUE TO LIST.

VALUE-KEY = '2'.
VALUE-TEXT = 'Country'.
APPEND VALUE TO LIST.

CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = NAME VALUES = LIST.

START-OF-SELECTION.
SELECT kunnr name1 UP TO 20 ROWS FROM kna1 INTO TABLE itab. SELECT kunnr land1 UP TO 20 ROWS FROM kna1 INTO TABLE jtab.

CASE option.
WHEN '1'.
 LOOP AT itab.
  WRITE:/ itab-kunnr,itab-name1.
 ENDLOOP.

WHEN '2'.
 LOOP AT jtab.
  WRITE:/ jtab-kunnr,jtab-land1.
 ENDLOOP.
ENDCASE.

Sunday, July 31, 2011

Useful Reports Tcode in SAP Financial Accounting

GENERAL LEDGER

Information Systems

1.  Structured Account Balances 
(Balance Sheet & P&L Account  in FS Version Format)               

                                                S_ALR_87012279
2.  GL Account Balances (Totals & Balances )    S_ALR_87012301
3.  GL Line Items                               S_ALR_87012282
4.  Statements for GL Accounts, 
Customers & Vendors  S_ALR_87012332 
5.  Document Journal                          S_ALR_87012287
6.  Compact Document Journal                  S_ALR_87012289
7.  Line Item Journal                         S_ALR_87012291
8.  Display of Changed Documents              S_ALR_87012293
9.  Invoice Numbers assigned Twice            S_ALR_87012341
10. Gaps in Document Number Assignments       S_ALR_87012342
11. Posting Totals Document Type wise         S_ALR_87012344
12. Recurring Entry Documents                 S_ALR_87012346

Master Data

13. Chart of Accounts                         S_AL:R_87012326
14. GL Account List                           S_AL:R_87012328
15. Display Changes to GL Accounts            S_ALR_87012308
16. Financial Statement Version               FSE2

CASH & BANK REPORTS

1. Check Information List                     FCH6
2. Check Register                             FCHN
3. Check Number Ranges                        S_P99_41000102


TAX REPORTS & REGISTERS

1. List of Internally generated 
Excise Invoices                              J1I7
2. Capital Goods Transfer of Credit          j2I8                           
3. List of GRs without Excise Invoice        j1IGR  

4. List of SubContract Challans              J1IFR

5. CENVAT Register                           J2I9
(Monthly Return under Rule 57AE of the 
Central excise Rules from which Monthly Return 
under Rule 7 of the CENVAT Credit Rules 2001)

6. Registers : RG 23A/C Part I &II , RG1, PLA  J1I5,J2I5,J2I6
ACCOUNTS RECEIVABLE

Information Systems

1. Bill Holdings 
(Bill of Exchange Receivable List  with ALV facility)
                                             S-ALR_87009987
2. Customer Balances in Local Currency       S_ALR_87012172
3. Customer Line Items                       S_ALR_87012197
4. Due Dates Analysis for Open Items         S_ALR_87012168
5. List of Customer Open Items               S_ALR_87012173
6. Customer Evaluation with Open 
Item Sorted List  S_ALR_87012176
7. Customer Payment History                  S_ALR_87012177
8. Customer Open Item Analysis 
(Overdue Items Balance) S_ALR_87012178
9. List of Customer Cleared Line Items       S_ALR_87012198
10.List of Down Payments open at key date    S_ALR_87012199
11. Debit & Credit Notes Register – Monthly  S_ALR_87012287
12. Customer wise Sales                      S_ALR_87012186                           

ACCOUNTS PAYABLE

(Note : Similar Reports available for A/R 
are available for A/P also)

1. Vendor Balances                           S_ALR_87012082
2. Vendor Debit/Credit Memo Register         S_ALR_87012287
Is there a Report displaying Master data, that is a list of vendors showing name, address, payment
method, etc ( everything about vendor).   Is their any report like that and what's the table name to display
all vendor master data too.  Go to this menu:
Financial Accounting -> Accounts Payable -> Information System -> Reports for AP accounting -> Master Data.
How to get Report of Withholding Tax along with Vendor Name.  What is the T-Code or Path for this report?
You can get the withholding tax report for vendor by using these t.codes:
S_P00_07000134 - Generic Withholding Tax Reporting 
S_PL0_09000447 - Withholding tax report for the vendor
Which reports we can use for the receivables to be checked on daily basis?
Go to SAP Easy Access main menu.
Go To Accounting -> FI Acc -> customer(receivables) -> information system -> reports . 
Here you can get all the standard reports for receivables.

Drop Down lists in the selection parameters

PROGRAM ztest.   TYPE-POOLS : vrm.   DATA : name TYPE vrm_id,        list TYPE vrm_values,        value LIKE LINE OF list. ...