Friday, December 24, 2010

ABAP: How to debug a program which is running in an endless loop

Imagine your program is running in an endless loop and you need to analyze its behavior. In such situations you can force the running program into the debugger simply by setting a session breakpoint in a second ABAP Editor. In Utilities->Settings...->Debugging just choose the Session breakpoint active immed. option. When you activate this option, all (running and waiting) sessions of your logon session immediately inherit all session breakpoints set in any of those sessions. It is recommended that you activate this option in development environments.

Saturday, December 11, 2010

ALV : Drag and Drop on rows


REPORT zalv_dragndrop.


*Structure declaration for T016T


TYPES : BEGIN OF ty_t016t,


brsch TYPE brsch,


brtxt TYPE text1_016t,


spras TYPE spras,


END OF ty_t016t.


*Work area and internal table for T016T


DATA : it_t016t TYPE STANDARD TABLE OF ty_t016t,


wa_t016t TYPE ty_t016t.


*class declaration


CLASS lcl_objdragdropapp DEFINITION DEFERRED.


*data declarations for alv


DATA: c_dragdropapp TYPE REF TO lcl_objdragdropapp,


c_dockingcont TYPE REF TO cl_gui_docking_container,


c_alv TYPE REF TO cl_gui_alv_grid,


* reference variable to CL_DRAGDROP:


c_dragdropalv TYPE REF TO cl_dragdrop,


it_layout TYPE lvc_s_layo,


it_fcat TYPE lvc_t_fcat. "Field catalogue


*declarations for handle event


DATA: effect TYPE i,


handle_alv TYPE i.


*start of selection event


START-OF-SELECTION.


*select data


PERFORM fetch_data.


*ALV output


PERFORM alv_output.


* Class definitions and method implementation for drag and drop


CLASS lcl_dragdrop DEFINITION.


PUBLIC SECTION.


DATA: wa TYPE ty_t016t,


index TYPE i. "Index of Line to be moved


ENDCLASS. "LCL_DRAGDROP DEFINITION


*Application class definition


CLASS lcl_objdragdropapp DEFINITION.


PUBLIC SECTION.


METHODS:


*Handling Event Drag


handle_alv_drag


FOR EVENT ondrag


OF cl_gui_alv_grid


IMPORTING e_row e_column e_dragdropobj,


*Handling event DROP


handle_alv_drop


FOR EVENT ondrop


OF cl_gui_alv_grid


IMPORTING e_row e_column e_dragdropobj.


ENDCLASS. "LCL_objdragdropapp DEFINITION


*Application class implementation


CLASS lcl_objdragdropapp IMPLEMENTATION.


* OnDrag event is used to 'fetch' information from the drag source.


METHOD handle_alv_drag.


DATA: dataobj TYPE REF TO lcl_dragdrop,


line TYPE ty_t016t.


* Read dragged row


READ TABLE it_t016t INDEX e_row-index INTO line.


* create and fill dataobject for events ONDROP


CREATE OBJECT dataobj.


* Remembering row index to move a line


MOVE e_row-index TO dataobj->index.


* store the dragged line.


READ TABLE it_t016t INTO dataobj->wa INDEX e_row-index.


* Assigning data object to the refering event parameter


e_dragdropobj->object = dataobj.


ENDMETHOD. "HANDLE_ALV_DRAG


*Event handler for event 'OnDrop'. This event is used


*to use your dragged information in combination with your drop source.


METHOD handle_alv_drop.


DATA: dataobj TYPE REF TO lcl_dragdrop,


drop_index TYPE i,


stable TYPE lvc_s_stbl.


* Refresh Alv Grid Control without scrolling


stable-row = 'X'.


stable-col = 'X'.


* Catch-Statement to ensure the drag&drop-Operation is aborted properly.


CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.


dataobj ?= e_dragdropobj->object.


DELETE it_t016t INDEX dataobj->index.


INSERT dataobj->wa INTO it_t016t INDEX e_row-index.


*Refreshing the ALV


CALL METHOD c_alv->refresh_table_display


EXPORTING


i_soft_refresh = 'X'


is_stable = stable.


ENDCATCH.


IF sy-subrc <> 0.


* If anything went wrong aborting the drag and drop operation:


CALL METHOD e_dragdropobj->abort.


ENDIF.


ENDMETHOD. "HANDLE_ALV_DROP


ENDCLASS. "LCL_objdragdropapp IMPLEMENTATION


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


*& Form alv_output


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


FORM alv_output .


CALL SCREEN 600.


ENDFORM. " alv_output


** Calling the ALV screen with custom container


*On this statement double click it takes you to the screen painter SE51.


*Enter the attributes


*Create a Custom container and name it CC_CONT and OK code as OK_CODE.


*Save check and Activate the screen painter.


*Now a normal screen with number 600 is created which holds the ALV grid.


* PBO of the actual screen ,Here we can give a title and customized menus


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


*& Module STATUS_0600 OUTPUT


*&---------------------------------------------------------------------*
MODULE status_0600 OUTPUT.


* SET PF-STATUS 'xxxxxxxx'.


* SET TITLEBAR 'xxx'.


IF c_alv IS INITIAL.


PERFORM alv_controls.


ENDIF.


ENDMODULE. " STATUS_0600 OUTPUT


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


*& Form alv_CONTROLS


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


FORM alv_controls.


* create docking container for alv control


CREATE OBJECT c_dockingcont


EXPORTING


dynnr = '600'


extension = 300


side = cl_gui_docking_container=>dock_at_top.


* create alv control


CREATE OBJECT c_alv


EXPORTING i_parent = c_dockingcont.


* create the application object to handle the ABAP Objects Events


CREATE OBJECT c_dragdropapp.


* Events alv control


*For Dragging


SET HANDLER c_dragdropapp->handle_alv_drag FOR c_alv.


*For Dropping


SET HANDLER c_dragdropapp->handle_alv_drop FOR c_alv.


* build tree nodes for drag&drop


PERFORM build_handle.


* Fieldcatalogue for ALV


PERFORM alv_build_fieldcat.


* ALV attributes FOR LAYOUT


PERFORM alv_report_layout.


* Call ALV GRID


CALL METHOD c_alv->set_table_for_first_display


EXPORTING


is_layout = it_layout


CHANGING


it_outtab = it_t016t


it_fieldcatalog = it_fcat


EXCEPTIONS


invalid_parameter_combination = 1


program_error = 2


too_many_lines = 3


OTHERS = 4.


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. "ALV_CONTROLS


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


*& Form build_handle


*&---------------------------------------------------------------------*
FORM build_handle.


* define a drag & Drop behaviour for the whole grid


CREATE OBJECT c_dragdropalv.


effect = cl_dragdrop=>move + cl_dragdrop=>copy.


CALL METHOD c_dragdropalv->add


EXPORTING


flavor = 'Line'


dragsrc = 'X'


droptarget = 'X'


effect = effect.


*getting the handle for drag and drop


CALL METHOD c_dragdropalv->get_handle


IMPORTING


handle = handle_alv.


ENDFORM. " build_handle


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


*& Form fetch_data


*&---------------------------------------------------------------------*
FORM fetch_data .


* select and display data from t016


SELECT brtxt brsch spras FROM t016t INTO CORRESPONDING FIELDS OF TABLE it_t016t


WHERE spras = 'EN'.


ENDFORM. " fetch_data


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


*& Form alv_report_layout


*&---------------------------------------------------------------------*
FORM alv_report_layout .


it_layout-grid_title = 'ALV Drag Drop'.


* provide handle to alv control to all rows for same drag & drop behaviour


it_layout-s_dragdrop-row_ddid = handle_alv.


ENDFORM. " alv_report_layout


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


*& Form alv_build_fieldcat


*&---------------------------------------------------------------------*
FORM alv_build_fieldcat .


DATA lv_fldcat TYPE lvc_s_fcat.


CLEAR lv_fldcat.


lv_fldcat-row_pos = '1'.


lv_fldcat-col_pos = '1'.


lv_fldcat-fieldname = 'BRSCH'.


lv_fldcat-tabname = 'IT_T016T'.


lv_fldcat-outputlen = 8.


lv_fldcat-scrtext_m = 'Industry'.


APPEND lv_fldcat TO it_fcat.


CLEAR lv_fldcat.


lv_fldcat-row_pos = '1'.


lv_fldcat-col_pos = '2'.


lv_fldcat-fieldname = 'BRTXT'.


lv_fldcat-tabname = 'IT_T016T'.


lv_fldcat-outputlen = 15.


lv_fldcat-scrtext_m = 'Description'.


APPEND lv_fldcat TO it_fcat.


CLEAR lv_fldcat.


ENDFORM. " alv_build_fieldcat


* PAI module of the screen created. In case we use an interactive ALV or


*for additional functionalities we can create OK codes


*and based on the user command we can do the coding.


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


*& Module USER_COMMAND_0600 INPUT


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

MODULE user_command_0600 INPUT.


ENDMODULE. " USER_COMMAND_0600 INPUT






Thursday, December 9, 2010

FI: Important T-Codes in FI

1. CHART OF ACCOUNTS


0BY7 = Copy chart of accounts.

2.FISCAL YEAR VARIANTS

OB29=define fiscal year variants

OBB0=define posting periods variants

3.COMPANY CODE CONFIGURATION

OX02=company code creation

OBY6=define company code global parameters

EC01=copy company code

OY01=define countries

OB22=define parallel currencies

4.BUSSINESS AREAS

OX03=define business areas

GGB0=define validations

OB28=activate FI validations

5.FUNCTIONAL AREAS.

OKBD=define functional areas.

GGB1=define substitution

GS01=create sets

OBBZ=create functional area substitution

6.SALES AND USE TAX.

OBBG=assign country to tax calculation procedure

OBCO=specify structure for the jurisdriction code

OBCP=define tax jurisdiction codes

FTXP=define codes on tax and purchases

OBCL=define tax code for non-taxable transactions

GENERAL LEDGER

1. CHART OF ACCOUNTS.

OBD4=define account groups.

FSP3=chart of account display

OB53=define retained earnings account

OB15=define sample account rule types

FSK2=define data transfer rules

OB67=allocate company codes to rule types

FSM1=create sample accounts

FS01=create G/L accounts master records

2. COPYING AND TRANSPORTING G/L ACCOUNTS.

OB49=transport chart of accounts

OBY2=copy company codes

OBC4=define field status groups

3.POSITION KEY CONFIGURATION.

OB41=define position key configuration.

4. AUTOMATIC ACCOUNT DETERMINATION.

FBKP=configure auto act determination

OBY0=define tax accounts auto act assignement

OBYA=define cross company code

5.FINANCIAL STATEMENT VERSION.

OB58=define financial statement version

6.G/L DISPLAY CONFIGURATION.

O7Z3=define line layouts

OBVU=add special fields

O7S7=define sort variants

O7R1=define total variants

7.TOLERENCE GROUPS.

OBAY=define tolerance groups

OB57=allocate isers to tolerance groups

8.NUMBER RANGES AND DOCUMENT TYPES

FBN1=define FI number ranges

OBA7=define FI document types

OBU1=define document types and posting keys

O7E6=define fast entry screen

ACCOUNTS PAYABLE A/P

1. HOUSE BANKS AND ACCOUNTS

FI12=define house banks

FCH1=define check lots

FCHV=define void reason codes

2. PAYMENT PROGRAM CONFIGURATION

FBZP=payment program configuration

3. VENDOR MASTER DATA

OBD=3define vendor groups

XKN1=create number ranges for vendor account groups

OBAJ=assign number ranges to vendor groups

FK15=copy vendor master records

FK16=important vendor master records

ACCOUNTS RESIVEABLR A/R

1. TERMS OF PAYMENTS AND INTEREST CALCULATION

OBB8=define terms of payments

OB46=define interest calculation types

OB82=make the interest indicator avail to interest run program

OBAC=define reference interest rates

OB81=assign reference interest rates to interest indicators

OBV1=interest calculations account assignment

2. REASON CODES.

OBBE=define reason codes

OBCR=define reason codes conversion version

OBCS=map external reason codes to internal reason codes

3. DEFAULT ACCOUNT ASSIGNMENT

OBXL=assign G/L account to reason codes

OBX1=cash discount accounts

4. OVERALL A/R AND EMPLOYEE TOLERENCES

OBA3=define customer tolerance groups

5. CREDIT MANAGEMENT

OB45=define credit control areas

OB01=define credit risk categories

OB02=define credit representative groups

OB51=assign employee credit representitive groups

OB39=define days in arrears calculation

6. CUSTOMER MASTER RECORDS.

OBD2=define customer groups

ACCOUNTS RESIVEABLR A/R

1. TERMS OF PAYMENTS AND INTEREST CALCULATION

OBB8=define terms of payments

OB46=define interest calculation types

OB82=make the interest indicator avail to interest run program

OBAC=define reference interest rates

OB81=assign reference interest rates to interest indicators

OBV1=interest calculations account assignment

2. REASON CODES.

OBBE=define reason codes

OBCR=define reason codes conversion version

OBCS=map external reason codes to internal reason codes

3. DEFAULT ACCOUNT ASSIGNMENT

OBXL=assign G/L account to reason codes

OBX1=cash discount accounts

4. OVERALL A/R AND EMPLOYEE TOLERENCES

OBA3=define customer tolerance groups

5. CREDIT MANAGEMENT

OB45=define credit control areas

OB01=define credit risk categories

OB02=define credit representative groups

OB51=assign employee credit representitive groups

OB39=define days in arrears calculation

6. CUSTOMER MASTER RECORDS.

OBD2=define customer groups

CONTROLLING ENTERPRISE STRUCTURE

1. CONTROLLING AREAS

OX06=controlling area maintenance

OKKP=activate relative CO components within

Controlling area

KANK=maintain number ranges

2. OPERATING CONCERNS

KEP8=maintain operating concerns

OKEQ=version configuration screen

COST ELEMENT ACCOUNTIN

1. AUTOMATIC COST ELEMENT CREATION

OKB2= automatic cost element creation

OKB3= creation of the cost elements

Creation batch run session

SM35= execution of the cost element creation

batch input session

2. MANUAL COST ELEMENT CREATION

KA06= seacondry cost element creation

KA01= primary cost element creation

3. IMPUTED COSTS

KSAZ= manual overhead costing sheet

Creation for imputed cost calculation

4. RECONCILATION LEDGER

KALA= activate the reconciliation ledger

OKKP= assignment of the reconciliation

Table to the controlling area

OBYB= maintain the CO-FI automatic account

Assignment configuration

OK13= assignment to the reconciliation ledger

Document number range

COST CENTER ACCOUNTING

1. C.C.ACCOUNTING STANDARD HIERACHRY

KSH2= C.C.A standard hierachry maint creation.

2. CO AREAS P.C.A MAINT.

OKES= maint the PCA CO area settings

OK59= creating the dummy profit center

3. COST CENTER BASICS

OKA2= cost center category maint

OKEG= maint of the time based fields

KS01=creating/main the cost center M. records

4. ACTIVITY TYPES STATSTICAL KEY FIGURE

KK01=creation / maint of statistical key figs

KVA5= activity independent key figs

KV06= creation of an allocation cost elements

OKEI= time based field maint for activity types

OKL01= creation maint of activity types

5. ASSESMENT –DISTRIBUTION AND REPORTING

KCAV= maint of the allocation character for the sender /receiver

KA06= creation/maint of the assessment cost element

KSWI= creation of the cost center reporting

KSV1= creation of the cost center distribution

KSU1= creation of the cost center assessment

6. COST CENTER ACCOUNTING PLANNING

KP97= copy planning for cost center accounting

KPU1=creation of the plan revaluation

KP65= creation of the cost planning layout

KP34=planning profile creation

OKB9=maint of the CO automatic account

INTERNAL ORDER ACCOUNTING

1. ORDER SETTELEMENT CONFIGURATION

KA01= primary cost element

KA06= secondary cost elements

OK06= settlement structure

OKEV= origin source structure

OK07= settlement profile

SNUM= maintain number range assignment

2. ORDER PLANNING AND BUDGITING

OKEQ= maintain CO versions

OKOS= define planning profile for overall value planning

OKOB= define budget profile

OK14= maintain budget manager

OPTK= define exempt cost element for availability control

KANK= maint number range assignment

OK11= maint number range for planning/ budgeting objects

3. INTERNAL ORDER STATUS MANAGEMENT

KOT2= define order status management

KOV2= define transaction groups

OK02= define status profile

BS52= define authorization keys

4. ORDER TYPE DEVELOPMENT

KOT2= define order types

PROFITABILITY ANALYSIS

1. OPERATION CONCERN DEVELOPMENTS

KEAO= maintain operation concerns

2. CHARACHTERISTIC DERICATION

KE4K= maint derivation

KE04= create derivation structure

KE05= change derivation structure

KE06= display derivation structure

KES1=maintain CO-PA master data

KE07= create derivation rules

KE08= change derivation rules

3. ASSIGNING VALUES TO VALUE FIELDS

KE41=assign condition types to value fields

KE4M= assign SD quantity fields to value fields

KE4W= reset value fields

KEI1= define PA settlement structure

KEU1= create CO-PA cost center assessment

KEV2= change CO-PA cost center assessment

4. CO-PA PLANNING

OKEQ= maintain plan versions

KEF1= define planning revaluation

KE14= create planning layouts

KE15= change planning layouts

KE16= display planning layouts

KP34= define planning profiles

KE4D= define external data transfer structure

KE4Z= define assignment groups

KE4E= define field assignment

KEN2= define plan number ranges

5. ACTIVITY CO-PA

KEKK= assign controlling areas to operating concerns

KEN1= define number ranges to actual postings

6. CO-PA REPORTING

KER1= define report line structure

KE34= create forms

KE35= change forms

KE36= display forms

KE31= create CO-PA reports

KE32= change CO-PA repots

KE33= display CO-PA reports

7. CO-PA TRANSPORTS

KE3I= create CO-PA transports

PROFIT CENTER ACCOUNTING

1. BASIC SETTINGS AND MASTER DATA REVIEW

OKE5= maintain controlling area setups

1KE1=analyze settings

OKE4= update settings

OKE7= maintain time based fields

2. ASSIGNEMENT IN PCA

1KEB= perform fast assignment

OKEM= sales order sub creation

OKEL= sales order dist sub creation

1KE4= PCA assignment monitor

3. ACTUAL POSTING MAINTAINANCE

1KEF= set control parameters for actual postings

GCBX= define document types for actual postings

OKB9= maintain default account assignment

3KEH= maintain add. Bal. sheet and P&L acts.

2KET= activate balance carry format for CO-PA

4. PCA PLANNING

OKEQ= maintain controlling versions

GCBA= define documents types for plan postings

GS01= set maintenance for plan parameters creation

GP41= create plan parameters for plan postings

KE62= copy data to plan

INVESTEMENT MANAGEMENT

1. PROGRAMS TYPES, INVESTEMENT MEASURES

AND INVESTMENT PROFILE

OIT3= define program types

OITA= define investment profiles

2. I.M PLANNING AND BUDGETING PROFILES

OIP1= define investment management plan profile

OIB1= define IM budget profile

OIT5= assign actual value to budget category

OK11= define IM management plan profile

Monday, December 6, 2010

Things to look out for Unicde Conversion

Hello,
Below are few hints which can be useful for Unicde conversion projetcs.
Transaction to check the objects which are relevant for Unicode conversion : UCCHECK

1. File Interface - OPEN DATASET

The majority of ABAP changes needed on SAP system for Unicode involve the file interface. This section describes the expected changes for OPEN DATASET, READ, and TRANSFER statements.

1.1 - OPEN...TEXT MODE

The non-Unicode syntax for accessing the file system in text mode is:

OPEN DATASET dsn FOR access IN TEXT MODE.

The expected change for this type of syntax for Unicode is:

OPEN DATASET dsn FOR access IN TEXT MODE ENCODING DEFAULT.

The value of FOR access (INPUT, OUTPUT, APPENDING, UPDATE) will remain the same.


1.2 - OPEN...BINARY MODE

The non-Unicode syntax for accessing the file system in binary mode is:

OPEN DATASET dsn FOR access IN BINARY MODE.

The expected change for this type of syntax for Unicode is:

OPEN DATASET dsn FOR access IN LEGACY BINARY MODE.

The value of FOR access (INPUT, OUTPUT, APPENDING, UPDATE) will remain the same.

1.3 - READ/TRANSFER

No change to the syntax of READ or TRANSFER is needed. However, a runtime error triggers if the OPEN statement does not exist for these statements.


2. WS_UPLOAD/WS_DOWNLOAD

Functions WS_UPLOAD, WS_DOWNLOAD, UPLOAD, and DOWNLOAD are being replaced. In all cases, the new function GUI_UPLOAD will replace functions WS_UPLOAD and UPLOAD, and function GUI_DOWNLOAD will replace functions WS_DOWNLOAD and DOWNLOAD.

The snippet below show examples of how GUI_UPLOAD and GUI_DOWNLOAD should be implemented. The designation implies carrying over the variable from

WS_UPLOAD, WS_DOWNLOAD, UPLOAD, or DOWNLOAD. Any new parameter supplied with GUI_UPLOAD or GUI_DOWNLOAD should remain commented out.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename =

filetype =

HAS_FIELD_SEPARATOR = ' '

header_length =

READ_BY_LINE = 'X'

dat_mode =

codepage =

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

CHECK_BOM = ' '

VIRUS_SCAN_PROFILE =

IMPORTING

filelength =

HEADER =

TABLES

data_tab =



CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize =

filename =

filetype =

WRITE_FIELD_SEPARATOR = ' '

col_select =

col_select_mask =

no_auth_check =

codepage =

wk1_n_format =

wk1_n_size =

wk1_t_format =

wk1_t_size =

IMPORTING

filelength =

TABLES

data_tab =

fieldnames = .

3. Character Strings and Byte Strings

The following statements can be used for processing character strings or byte strings.

CONCATENATE, FIND, SEARCH, REPLACE, SHIFT, SPLIT, CONDENSE, CONVERT TEXT, OVERLAY, TRANSLATE.

Research into the data object type used with the above statements must be done to find the appropriate syntax update. If the data object type is CHARACTER, no syntax changes are necessary. The addition IN CHARACTER MODE is made by default with no changes to the code. For example:

The addition IN CHARACTER MODE is not needed.

CONCATENATE x1 x2 INTO result.

If the data object type is BYTE, add the addition IN BYTE MODE. For example:

CONCATENATE x1 x2 INTO result IN BYTE MODE.

=4. Find Distance of Strings
DESCRIBE...DISTANCE

Research into the data object types used with DESCRIBE...DISTANCE must be done to find the appropriate syntax update.

If the data object type is CHARACTER, use:

DESCRIBE DISTANCE BETWEEN dobj1 AND dobj2 INTO off IN CHARACTER MODE.

If the data object type is BYTE, use:

DESCRIBE DISTANCE BETWEEN dobj1 AND dobj2 INTO off IN BYTE MODE.

Examples

OPEN.......TEXT

Non-Unicode

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.

Unicode

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. " Unicode

Unicode to Replace UPLOAD or WS_UPLOAD

Data: filename TYPE String.

Constants: c_tab TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab.

call function 'GUI_UPLOAD'

exporting

filename = filename

has_field_separator = c_tab

tables

data_tab = tl_upltext

exceptions

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_table_width = 4

invalid_type = 5

no_batch = 6

unknown_error = 7.



CONCATENATE

Non-Unicode

DATA: x1(1) TYPE x,

x2(1) TYPE x,

result(2) TYPE x.

. . .

CONCATENATE x1 x2 INTO result.

Unicode

DATA: x1(1) TYPE x,

x2(1) TYPE x,

result(2) TYPE x.

. . .

CONCATENATE x1 x2 INTO result IN BYTE MODE.


DESCRIBE

Non-Unicode

DATA: f1(10) TYPE c,

ilen TYPE i.

. . .

DESCRIBE FIELD f1 LENGTH ilen.

Unicode

DATA: f1(10) TYPE c,

ilen TYPE i.

. . .

DESCRIBE FIELD f1 LENGTH ilen IN CHARACTER MODE.

Cheers,
Sandeep

Sunday, December 5, 2010

User types in SAP

User Type : Dialog 'A'

A normal dialog user is used by one person only for all types of logon.

During a dialog logon, the system checks for expired and initial passwords and provides an option to change the password.Multiple dialog logons are checked and logged if necessary.

User Type :System 'B'

You use a user of type System for communication without dialog within one system (for RFC or CPIC service users) or for background processing within one system.

Dialog logon is not possible.

A user of this type is excluded from the general settings for password validity. Only the user administrator can change the password using transaction SU01 (Goto -> Change Password).

User Type :Communication 'C'

You use a user of type Communication for communication without dialog between systems (for RFC or CPIC service users for various applications, for example, ALE, Workflow, TMS, CUA).

Dialog logon is not possible.

User Type :Service 'S'

A user of the type Service is a dialog user that is available to an anonymous, larger group of users. Generally, this type of user should only be assigned very restricted authorizations.

For example, service users are used for anonymous system access via an ITS service. Once an individual has been authenticated, a session that started anonymously using a service user can be continued as a personal session using a dialog user.

During logon, the system does not check for expired and initial passwords. Only the user administrator can change the password.

Multiple logon is allowed.

User Type :Reference 'L'

Like the service user, a reference user is a general user, not assigned to a particular person. You cannot log on using a reference user. The reference user is only used to assign additional authorization. Reference users are implemented to equip Internet users with identical authorizations.

On the Roles tab, you can specify a reference user for additional rights for dialog users. Generally, the application controls the allocation of reference users. You can allocate the name of the reference user using variables. The variables should begin with "$". You assign variables to reference users in transaction SU_REFUSERVARIABLE.

This assignment applies to all systems in a CUA landscape. If the assigned reference user does not exist in one of the CUA child systems, the assignment is ignored.

ABAP: Convert Spool List to ALV Grid

Hello,
At times we need to submit programs in background mode(batch jobs) , but the output needs to be displayed in the form of ALVs.
Here is sample code for the same.

Convert Spool List to ALV Grid



FUNCTION ztest_conv_spool_list_alv.


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


*"*"Local Interface:


*" IMPORTING


*" REFERENCE(I_SPOOLN) TYPE CHAR10


*" REFERENCE(I_KEEP_SUM_LINE) TYPE BOOLEAN DEFAULT 'X'


*" REFERENCE(I_START_TABLE) TYPE INT4 DEFAULT 1


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


TYPE-POOLS: slis.


TABLES: tsp01.


DATA: BEGIN OF gtbl_data OCCURS 0,


data(2048) TYPE c,


END OF gtbl_data.


DATA: BEGIN OF gtbl_col OCCURS 0,


col(255) TYPE c,


END OF gtbl_col.


DATA gv_line TYPE i.


DATA gv_length TYPE i.


DATA gv_cnt TYPE i.


DATA gv_dec TYPE i.


DATA gv_row(2048) TYPE c. "string.


DATA gv_row_d(2048) TYPE c. "string.


DATA gv_spoolnum TYPE tsp01-rqident.


DATA gtbl_fieldcat TYPE slis_t_fieldcat_alv.


DATA gstr_fieldcat LIKE LINE OF gtbl_fieldcat.


DATA gstr_data LIKE LINE OF gtbl_data.


DATA gstr_data_d LIKE LINE OF gtbl_data.


DATA gtbl_match TYPE match_result_tab.


DATA gtbl_match_last TYPE match_result_tab.


DATA gtbl_fcat TYPE lvc_t_fcat.


DATA gstr_fcat LIKE LINE OF gtbl_fcat.

DATA gref_data TYPE REF TO data.


DATA gref_new_line TYPE REF TO data.


FIELD-SYMBOLS: <fs_data> TYPE REF TO data.


FIELD-SYMBOLS: <fs_dyntable> TYPE STANDARD TABLE.


FIELD-SYMBOLS: <fs_match> LIKE LINE OF gtbl_match.


FIELD-SYMBOLS: <fs_dynline> TYPE ANY.


FIELD-SYMBOLS: <fs_dynstruct> TYPE ANY.


*******************************************************************************


" Read the spool


gv_spoolnum = i_spooln.


CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'


EXPORTING


rqident = gv_spoolnum


TABLES


buffer = gtbl_data.


*******************************************************************************


" Pre-check to make sure we have a list


" simply checking the first char of the


" first and the last line


READ TABLE gtbl_data INTO gstr_data INDEX 1.


IF sy-subrc = 0.


IF gstr_data-data(1) <> '-'.


MESSAGE 'Spool does not contain any ALV list' TYPE 'E'.

ELSE.


" Number of rows


gv_line = LINES( gtbl_data ).


" Read the last line


READ TABLE gtbl_data INTO gstr_data INDEX gv_line.


IF sy-subrc = 0.


IF gstr_data-data(1) <> '-'.


MESSAGE 'Spool does not contain any ALV list' TYPE 'E'.


ENDIF.


ENDIF.


ENDIF.


ENDIF.


*******************************************************************************


" Start with the N table in the spool.


IF i_start_table > 1.


FREE gv_line.


gv_dec = i_start_table.


SUBTRACT 1 FROM gv_dec.


gv_dec = gv_dec * 2.


" Find the end of the table N - 1


LOOP AT gtbl_data INTO gstr_data WHERE data(1) = '-'.


ADD 1 TO gv_line.


IF gv_line = gv_dec.


gv_dec = sy-tabix.


EXIT.


ENDIF.


ENDLOOP.


" Delete the rows up table N


DELETE gtbl_data FROM 1 TO gv_dec.


ENDIF.


*******************************************************************************


" Check how many ALV list are in the spool


" and make sure if more than one the # of columns are matching


FREE gv_line .


LOOP AT gtbl_data INTO gstr_data WHERE data(1) = '-'.


ADD 1 TO gv_line.


gv_cnt = gv_line MOD 2.


" The column headings are on odd number in our find counter


IF gv_cnt <> 0.


" Save the find counter value


gv_cnt = gv_line.


" Update index to point to column heading row and read


gv_line = sy-tabix + 1.


READ TABLE gtbl_data INDEX gv_line INTO gstr_data.


gv_row = gstr_data-data.


" Find the columns: position and length


FIND ALL OCCURRENCES OF '
' IN gv_row RESULTS gtbl_match.


" Compare the previous heading w/ current


IF gtbl_match[] <> gtbl_match_last[] AND sy-tabix > 2.


MESSAGE 'Spool contains more than one ALV list where column headings are different.' TYPE 'E'.


ENDIF.


FREE: gtbl_match_last, gv_row.


gtbl_match_last[] = gtbl_match[].


FREE gtbl_match.


" Get back the find counter value


gv_line = gv_cnt.


ENDIF.


ENDLOOP.


*******************************************************************************


" Read column heading row


READ TABLE gtbl_data INDEX 2 INTO gstr_data.


gv_row = gstr_data-data.


" Read also the first data row


" Here we are assuming tha the first row all fields


" filled in; will use this to determine mumeric or char


READ TABLE gtbl_data INDEX 4 INTO gstr_data_d.


gv_row_d = gstr_data_d-data.


" Find out the columns


FIND ALL OCCURRENCES OF '
' IN gv_row RESULTS gtbl_match.


FREE: gv_cnt, gv_line.


" Setup the field catalog for itab


LOOP AT gtbl_match ASSIGNING <fs_match>.


IF sy-tabix > 1.


" Field length


gv_length = <fs_match>offset gv_line + 1.


" Update counter used for column heading


ADD 1 TO gv_cnt.


" Used for dynamic itab


gstr_fcat-datatype = 'C'.


gstr_fcat-fieldname = gv_cnt.


gstr_fcat-intlen = gv_length.


gstr_fcat-tabname = ''.


" Debug and you will see why...


SUBTRACT 1 FROM gv_length.


" Used for ALV grid


gstr_fieldcat-reptext_ddic = gv_row+gv_line(gv_length).


gstr_fieldcat-tabname = ''.


gstr_fieldcat-fieldname = gv_cnt.


gstr_fieldcat-just = 'L'.


gstr_fieldcat-outputlen = gv_length.


APPEND gstr_fcat TO gtbl_fcat.


APPEND gstr_fieldcat TO gtbl_fieldcat.


FREE: gstr_fcat, gstr_fieldcat, gv_dec.


ENDIF.


" Start position of next column


gv_line = <fs_match>-offset + 1.


ENDLOOP.


ASSIGN gref_data TO <fs_data>.


*******************************************************************************


" Create a dynamic table based on the number of columns above


CALL METHOD cl_alv_table_create=>create_dynamic_table


EXPORTING


it_fieldcatalog = gtbl_fcat


IMPORTING


ep_table = <fs_data>


EXCEPTIONS


generate_subpool_dir_full = 1


OTHERS = 2.


ASSIGN <fs_data>->* TO <fs_dyntable>.


" Create a new mem area


CREATE DATA gref_new_line LIKE LINE OF <fs_dyntable>.


" Now point our <FS_*> to the mem area


ASSIGN gref_new_line->* TO <fs_dynstruct>.


ASSIGN gref_new_line->* TO <fs_dynline>.


*******************************************************************************


" Remove column headings that appears in the middle


" which are caused due to spool page-break


LOOP AT gtbl_data INTO gstr_data_d FROM 4 WHERE data = gstr_data-data.


DELETE gtbl_data.


ENDLOOP.


*******************************************************************************


" Push data to itab


LOOP AT gtbl_data INTO gstr_data.


" The first 3 rows are col heading related


IF sy-tabix > 3 AND (


gstr_data-data(2) <> '
-' AND " Column heading row


gstr_data-data(2) <> '--' " End of list row


).


REPLACE FIRST OCCURRENCE OF '
' IN gstr_data-data WITH space.


SPLIT gstr_data AT '
' INTO TABLE gtbl_col.


gv_cnt = 0.


" Split above makes each column to a row


" Get each column


LOOP AT gtbl_col.


ADD 1 TO gv_cnt.


ASSIGN COMPONENT gv_cnt OF STRUCTURE <fs_dynstruct> TO <fs_dynline>.


" Remove space front/end


CONDENSE gtbl_col-col.


MOVE gtbl_col-col TO <fs_dynline>.


ENDLOOP.


APPEND <fs_dynstruct> TO <fs_dyntable>.


gv_cnt = 0.


FREE: gtbl_col.


ENDIF.


FREE gstr_data.


ENDLOOP.


*******************************************************************************


" Sum line flag, keep or delete


IF i_keep_sum_line IS INITIAL.


LOOP AT <fs_dyntable> ASSIGNING <fs_dynline>.


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


DELETE <fs_dyntable>.


ENDIF.


ENDLOOP.


ENDIF.


*******************************************************************************


" Display


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING


it_fieldcat = gtbl_fieldcat


TABLES


t_outtab = <fs_dyntable>.


ENDFUNCTION.