Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts

Monday, July 30, 2012

Restrict User Authorization for layouts

 

Controlled by Authorization Object : S_ALV_LAYO

But this will restrict their access to maintain user Specific  Layout also.

 

 

 

Reference

http://scn.sap.com/thread/1025300

https://scn.sap.com/thread/304062

http://www.sapfans.com/forums/viewtopic.php?f=24&t=320732

SAP Notes:

409190

601803

Thursday, July 19, 2012

WRITE statement in ABAP


*&-Code extract to demonstrate the SAP write command-----------*
*&                                                             *
*& Author : www.sapdev.co.uk                                   *
*&  SAP ABAP development                                       *
*&-------------------------------------------------------------*


****************************************************************
*End-OF-selection.
End-OF-selection.


  write:/10(45) 'Total No of Employees entered:', gd_records,  "/10 indents 10 chars
        /10(45) 'Number of Employees processed successfully:', "(45) sets field lenth
                gd_success. "displays variable
  NEW-LINE.  "moves to a new line

  describe table it_error lines gd_lines. "gets number of records in a table
  check gd_lines gt 0.  "check there are some error records

  skip 2. "skips 2 lines
  write:/10 'Unsuccessful Employee records'.  "(10) makes field take up 10 chars
  write:/10 sy-uline(67).   "sy-uline(67) display a line 67 chars long

  write:/10  sy-vline,   "sy-vline creates a vertical line
        (10) 'Employee' COLOR COL_HEADING, sy-vline, "COLOR changes background colour
        (50) 'Description'  COLOR COL_HEADING, sy-vline.

  write:/10 sy-uline(67).     "display a line 67 chars long

  loop at it_error into wa_error.  "loops at err table
    write:/10  sy-vline,      "sy-vline creates a vertical line
          (10) wa_error-pernr, sy-vline,  "(10) makes field take up 10 chars
          (50) wa_error-text, sy-vline.
  endloop.

  write:/10 sy-uline(67). "display a line 67 chars long

Tables : User Authorizations

http://www.sapfans.com/forums/viewtopic.php?f=24&t=10145

image

Activate Save Layout option in ALV Grid Display

 

g_repid = sy-repid.
call function ‘REUSE_ALV_GRID_DISPLAY’
exporting
i_callback_program = g_repid
* i_structure_name = ‘ZSDR075′
it_fieldcat = i_fieldcat[]
i_save = ‘U’
tables
t_outtab = i_out[]
exceptions
program_error = 1
others = 2
Without a call back program, you cannot save, because it does not know what
program to attach the saved layouts to.
Value range for I_SAVE
‘ ‘ = Display variants cannot be saved
Defined display variants (such as delivered display variants) can be
selected for presentation regardless of this indicator. However,
changes cannot be saved.
‘X’ = Standard save mode
Display variants can be saved as standard display variants.
Saving display variants as user-specific is not possible.
‘U’ = User-specific save mode
Display variants can only be saved as user-specific.
‘A’ = Standard and user-specific save mode
Display variants can be saved both as user-specific and as standard
variants. Users make their choice on the dialog box for saving the
display variant.

Delete Duplicate Records

REPORT Z_TEST_REPORT.
data:

BEGIN OF itab OCCURS 0,

kunnr type kna1-kunnr,
name1 type kna1-name1,

END OF itab.

START-OF-SELECTION.

"we want to get data from the customer table where the keys
"are found in the sales order table (VBAK)

select kna1~kunnr kna1~name1 into CORRESPONDING FIELDS OF TABLE
itab from kna1 inner join vbak on
kna1~kunnr = vbak~kunnr.

sort itab by kunnr.

"There should be multiple customers data selected,
"Now if you want to show only 1 records per customer
"and remove all the duplicate rows, you can use the
"Delete Adjacent duplicates statement.

"Using Adjacent Duplicates to delete multiple rows
delete ADJACENT DUPLICATES FROM itab COMPARING kunnr.

LOOP AT itab.
WRITE :/ itab-kunnr, itab-name1.
ENDLOOP.

Here’s a snapshot from itab at debugger screen, as you see there are multiple customers id in the internal table.

kunnr

Here’s the result, now you don’t see any duplicates records. The comparing block at the Adjacent duplicates syntax can consists of more than one fields, for example comparing kunnr name1.

kunnr2

Select Option in ABAP

 

For any ABAP Report or an executable giving the selection criterion is important. Presenting the user with selection screen is very easy using Select-Options and Parameters in SAP ABAP.
The basic for of Select-Options in SAP ABAP is as follows.

Select-options: s_vbeln for vbak-vbeln.

In the above statement s_vbeln is defined as an internal table. And it has the following fields.

‘SIGN:’, s_vbeln-sign,
‘OPTION:’, s_vbeln-option,
‘LOW:’, s_vbeln-low,
‘HIGH:’, s_vbeln-high.

__________________________________________________________

Valid data types of f include all elementary ABAP types except data type f. You cannot use data type f, references, or aggregate types.
We will explore Select Options with the help of a small program shown below.

__________________________________________________________

REPORT ZEX_SELECTOPTIONS.
Tables: VBAK,
VBAP.
Data: int_vbak type vbak occurs 0 with header line.
Select-options: s_vbeln for vbak-vbeln.
Select * INTO int_VBAK from VBAK where
VBELN in s_vbeln.
APPEND int_VBAK.
CLEAR int_VBAK.
ENDSELECT.
Loop at s_vbeln.
WRITE: / ‘SIGN:’, s_vbeln-sign,
‘OPTION:’, s_vbeln-option,
‘LOW:’, s_vbeln-low,
‘HIGH:’, s_vbeln-high.
Endloop.
loop at int_vbak.
Write:/ int_vbak-vbeln, int_vbak-AUART.
endloop.

_______________________________________________________

Once the above program is executed, then the user is presented with a selection screen as shown below.
Sales Order No. ___________| to ___________ >>
Basically here you can enter the Sales Order Number as follows.
1) Single Entry
2) Range
3) Selected Sales Order Numbers
In case the user enters only a single Sales Order number then only one order gets selected and the output of the code,

Loop at s_vbeln.
WRITE: / ‘SIGN:’, s_vbeln-sign,
‘OPTION:’, s_vbeln-option,
‘LOW:’, s_vbeln-low,
‘HIGH:’, s_vbeln-high.
Endloop.

is as Follows

SIGN: I OPTION: EQ LOW: 4969 HIGH:
_________________________________________

In case the user enters a range from 4969 to 4977 then the output of the above code is

SIGN: I OPTION: BT LOW: 4969 HIGH: 4977
_______________________________________________

In case the user enters only selected values as 4969, 4970, 4971, 4972 the the output will be as follows.

SIGN: I OPTION: EQ LOW: 4969 HIGH:
SIGN: I OPTION: EQ LOW: 4970 HIGH:
SIGN: I OPTION: EQ LOW: 4971 HIGH:
SIGN: I OPTION: EQ LOW: 4972 HIGH:
SIGN: I OPTION: EQ LOW: 4973 HIGH:
______________________________________________

Note: The output shown above is for the internal table of select options. The result of the selected Sales Order will be different. You can run the code given above and see the output

Basic ABAP for Beginners

The following post is not users who are new to ABAP.

Step for creating a Simple report in ABAP.

References:
http://www.saptechnical.com/Tutorials/ABAP/InteractiveReport/Demo.htm

http://www.saptechnical.com/Tutorials/SAPQuery/ABAPCode/Page1.htm

Documents

Program to Display Composite roles –> Single Roles –> TCodes   (Request for Access)

SAP Query Reports

 

Setting-up a Role for the InfoSet Query

Reference Link : http://help.sap.com/saphelp_dimp50/helpdata/EN/86/0bf9392486ce1ae10000000a114084/content.htm

Use

To be able to create an InfoSet Query, the system administrator must set up a role for the work with the InfoSet Query.

Roles can be assigned to SAP user groups in SQ013 instead of individual user names.

Procedure

1.      A role has to be assigned specifically to a single SAP Query user group. This is because the InfoSet Query is derived from the SAP Query.

a.       Call up the Role Maintenance (RSQ10). You get to a table containing the roles that are relevant for working with the InfoSet Query.

b.       Choose the role you want, and use the Assign User Group function (second column in the table) to assign a user group to the role, or to remove an existing assignment.

When you are assigning user groups, a dialog box appears asking you if you want to create a new user group, or use an existing one. Use the input help to choose from the available user groups. It is not possible to assign a user group to more than one role.

When you have assigned a user group successfully to a role, the name of this user group appears in the third column of the table.

It is also possible to jump to the Query Builder from the SAP Easy Access SAP Business Information Warehouse Menu by selecting the InfoSet Query entry from the roles in the user menu.

2.      Assign Classic InfoSets to the role. Use the Assign Classic InfoSets function to do this (fifth column in the table).

A screen containing all the available Classic InfoSets appears. Select the InfoSets that you want to be able to use for defining queries within the role.

You are able to choose one of the selected Classic InfoSets as a standard Classic InfoSet (entry in the fourth column of the table). The standard Classic InfoSet is subsequently used as a template, if the components for maintaining InfoSet Queries are called using the menu entry mentioned above.

3.      In the Maintain Role transaction (PFCG) you assign the role you have set up to those users, who are going to work with the InfoSet Query.