Powered By

Free XML Skins for Blogger

Powered by Blogger

Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Saturday, October 18, 2008

SAP ABAP/4 Program: Describe Select-Options

When printing a report, you can print the search conditions or report parameters that the user entered. For instance, if a report output was restricted to plants between 1011 and 1501, you may want to print "Plants Between 1011 and 1501" on the report. This procedure describes the selected parameters.

Describe Select-Options


select-options: sel_opt for sy-datum.
.
.
.
loop at sel_opt.
perform describe_select_options using 'Date'
sel_opt-sign
sel_opt-option
sel_opt-low
sel_opt-high
changing datedesc.
write: / datedesc.
endloop.
.
.
.
*&---------------------------------------------------------------------*
*& Form DESCRIBE_SELECT_OPTIONS
*&---------------------------------------------------------------------*
form describe_select_options using
field_name type c "name to describe field (e.g. "Date")
sel_opt_sign like sel_opt-sign
sel_opt_option like sel_opt-option
sel_opt_low like sel_opt-low
sel_opt_high like sel_opt_high
changing descline type c. "line that will hold the one-line description
if sel_opt_sign = 'i'.
concatenate 'Include' field_name into descline separated by space.
else.
concatenate 'Exclude' field_name into descline separated by space.
endif.
case sel_opt_option.
when 'EQ'.
concatenate descline '=' sel_opt_low into descline
separated by space.
when 'BT'.
concatenate descline 'between' sel_opt_low 'and' sel_opt_high
into descline separated by space.
when 'NB'.
concatenate descline 'not between' sel_opt_low 'and' sel_opt_high
into descline separated by space.
when 'NE'.
concatenate descline '!=' sel_opt_low into descline
separated by space.
when 'GE'.
concatenate descline '>=' sel_opt_low into descline
separated by space.
when 'LE'.
concatenate descline '<=' sel_opt_low into descline
separated by space.
when 'GT'.
concatenate descline '>' sel_opt_low into descline
separated by space.
when 'LT'.
concatenate descline '<' sel_opt_low into descline
separated by space.
endcase.
endform. " describe_select_options

SAP ABAP/4 Program: Output Table Fields to a List

When you're looking at the structure of a table, SAP will let you print the structure, but it won't let you save the structure. This can be annoying. This report outputs the table structure to a list. At this point the user can use the System->List->Save->Local file command to save the list to a file.

Output Table Fields to a List


*&---------------------------------------------------------------------*
*& Report YTABFLDS *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT YTABFLDS .
TABLES: DD02L, DD03L, DD04T.

PARAMETERS THETABLE LIKE DD02L-TABNAME OBLIGATORY.
DATA: BEGIN OF MYTABLE,
TABNAME LIKE DD02L-TABNAME,
AS4LOCAL LIKE DD02L-AS4LOCAL,
AS4VERS LIKE DD02L-AS4VERS,
END OF MYTABLE.

SELECT SINGLE TABNAME AS4LOCAL AS4VERS INTO MYTABLE FROM DD03L
WHERE TABNAME = THETABLE.
WRITE: / MYTABLE-TABNAME, 11 MYTABLE-AS4LOCAL, 13 MYTABLE-AS4VERS.
SELECT * FROM DD03L
WHERE TABNAME = MYTABLE-TABNAME AND
AS4LOCAL = MYTABLE-AS4LOCAL AND AS4VERS = MYTABLE-AS4VERS.
WRITE: / DD03L-FIELDNAME, 11 DD03L-KEYFLAG, 13 DD03L-ROLLNAME,
24 DD03L-CHECKTABLE, 35 DD03L-INTTYPE, 37 DD03L-REFTABLE,
48 DD03L-DATATYPE.
SELECT SINGLE * FROM DD04T
WHERE ROLLNAME = DD03L-ROLLNAME AND
AS4LOCAL = MYTABLE-AS4LOCAL AND AS4VERS = MYTABLE-AS4VERS AND
DDLANGUAGE = 'E'.

WRITE: 53 DD04T-DDTEXT.
ENDSELECT.

SAP ABAP/4 Program: Outstanding PO Report

This report displays information for outstanding purchase orders. The report has two parts: one is the standard report, and the other is called from the Project Expense report. Note that both reports output GL Account, cost center, and cost object information (from table EKKN) as a single value on the output line. Actually, each line may have several cost centers and cost object to which the invoices were allocated; however, the user only wanted one (any one) to be listed.

Standard Report: The standard report lists info (limited by selection criteria) for purchase order items whose GR and IR are not equal. The report first accesses the header table EKKO, limited by purchasing group and purchase order. It then accesses EKPO, limited by PO item and material selection criteria. An internal table sums keeps subtotals of the related GR/IR quantities and values, read from EKBE, for the given PO and item. In the fill_sums routine, the subtotals are grouped by Credit/Debit indicator (EKBE-SHKZG), account assignment (EKBE-ZEKKN), and PO Doc Category (EKBE-BEWTP). These subtotals are then processed by the fill_outtab routine, which makes the GR/IR totals and compares them. If they are unequal, data is looked up further from EKKN, and the item is output.

Report Called from Project Expense Report: The report called from the Project Expense Report is the same as the standard report except that:

the compare variable is set to value 'A'.
records are outputted if GR < IR, or if both GR and IR are zero
selection criteria is based on the data in the po_itemp select-options list. This list is filled when the report is called
project number is output (project number is looked up in the po_aufnr select-options list which is filled when the report is called)
subtotals are not outputted
Outstanding PO Report


*&---------------------------------------------------------------------*
*& Outstanding POs *
*& *
*& ekbe has GR/IR records. If there is account assignment (ekpo-knttp *
*& is not blank), then ekkn will also have records related to the ekbe *
*& records. First check ekbe to see if GR/IR are unequal. If they are, *
*& list them and show related info. *
*& *
*& The ekkn table may contain several records with different G/L Accts *
*& Cost Centers, and/or Cost Objects. This report selects one record *
*& at random and uses it to get this data. Thus the *
*& report's output is somewhat misleading, as the G/L, Cctr, and CObj *
*& are listed as a single value rather than several values. A better *
*& implementation would list this info in sub-records (e.g. drill-down)*
*&---------------------------------------------------------------------*

REPORT ZGRIROPO LINE-SIZE 250 LINE-COUNT 65 NO STANDARD PAGE HEADING.
TABLES: EKBE, EKPO, EKKO, EKKN, BSIS.
PARAMETERS: COMPARE TYPE C NO-DISPLAY.
SELECT-OPTIONS:
PO_DOC FOR EKPO-EBELN, "Purchase order
PO_ITEM FOR EKPO-EBELP,"Purchase order item
PUR_GRP FOR EKKO-EKGRP,"Purchasing Group
MAT_NR FOR EKPO-MATNR, "material #
SEL_ACCT FOR EKPO-KNTTP, "account assignment category
POSTDAT FOR SY-DATUM NO-DISPLAY, "posting date
"transfer of params from project expense report
PO_ITEMP FOR EKPO-EBELN NO-DISPLAY, "PO/item pair
PO_AUFNR FOR BSIS-AUFNR NO-DISPLAY. "PO/order pair

DATA:
LN TYPE I, "subtotal for cost objects
TOTAL LIKE EKBE-DMBTR,
OLDSAKTO LIKE EKKN-SAKTO,
OLDKOSTL LIKE EKKN-KOSTL,
OLDKSTRG LIKE EKKN-KSTRG,
DO_SUBTOTAL TYPE C,
WROTE_SUBT TYPE C,
BEGIN OF COBJ_SUBTOTAL,
MENGE LIKE EKBE-MENGE,
GR LIKE EKBE-MENGE,
IR LIKE EKBE-MENGE,
ESTGRVAL LIKE EKBE-DMBTR,
IRVAL LIKE EKBE-DMBTR,
OUT LIKE EKBE-MENGE,
ESTOUTVAL LIKE EKBE-DMBTR,
END OF COBJ_SUBTOTAL,
BEGIN OF TOTALS.
INCLUDE STRUCTURE COBJ_SUBTOTAL.
DATA:END OF TOTALS,
EKKOEBELN LIKE EKKO-EBELN, "for ekko data
BEGIN OF MYEKPO, "for ekpo data
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
NETPR LIKE EKPO-NETPR,
KNTTP LIKE EKPO-KNTTP,
TXZ01 LIKE EKPO-TXZ01,
END OF MYEKPO,
BEGIN OF MYEKKN,
* zekkn like ekkn-zekkn,
MENGE LIKE EKKN-MENGE,
VPROZ LIKE EKKN-VPROZ,
SAKTO LIKE EKKN-SAKTO,
KOSTL LIKE EKKN-KOSTL,
KSTRG LIKE EKKN-KSTRG,
END OF MYEKKN,

BEGIN OF SUMS OCCURS 20, "totals for gr and ir
ZEKKN LIKE EKBE-ZEKKN, "Acct assignment serial
BEWTP LIKE EKBE-BEWTP, "PO Doc category
MENGE LIKE EKBE-MENGE, "GR/IR Quantity
DMBTR LIKE EKBE-DMBTR, "GR Value
SHKZG LIKE EKBE-SHKZG, "Debt/Credit indicator
END OF SUMS,

BEGIN OF OUTTAB OCCURS 1000, "output list
EBELN LIKE EKPO-EBELN, "PO Doc
EBELP LIKE EKPO-EBELP, "PO item
ZEKKN LIKE EKKN-ZEKKN, "account serial #
SAKTO LIKE EKKN-SAKTO, "G/L acct
KOSTL LIKE EKKN-KOSTL, "cost center
KSTRG LIKE EKKN-KSTRG, "cost object
MENGE LIKE EKPO-MENGE, "Quantity (total)
TXZ01 LIKE EKPO-TXZ01, "short text
GR LIKE EKPO-MENGE, "GR Quantity
ESTGRVAL LIKE EKBE-DMBTR,
GRVAL LIKE EKBE-DMBTR, "GR Value
IR LIKE EKPO-MENGE, "IR Quantity
IRVAL LIKE EKBE-DMBTR, "IR Value
OUT LIKE EKPO-MENGE, "Outstanding IR quantity
OUTVAL LIKE EKPO-BRTWR, "Outstanding IR value
ESTOUTVAL LIKE EKPO-BRTWR, "Estimated Outstanding IR Value
END OF OUTTAB.

AT SELECTION-SCREEN.
IF PUR_GRP IS INITIAL AND PO_DOC IS INITIAL.
MESSAGE E007(ZS).
ENDIF.

START-OF-SELECTION.
* should do authorization checking here **
SELECT EBELN FROM EKKO "select POs from pur grp and po doc
INTO EKKOEBELN
WHERE LOEKZ = ' ' AND "not to be deleted
EKGRP IN PUR_GRP AND "criteria
EBELN IN PO_DOC
ORDER BY EBELN.
* should do authorization checking here **
SELECT EBELN EBELP MENGE NETPR KNTTP TXZ01
FROM EKPO "select POs from material criteria
INTO MYEKPO
WHERE LOEKZ = ' ' AND "not to be deleted
KNTTP IN SEL_ACCT AND
EBELN = EKKOEBELN AND
EBELP IN PO_ITEM AND
MATNR IN MAT_NR
ORDER BY EBELN EBELP.
IF COMPARE = 'A'. "only use PO/item pairs passed from proj exp
LOOP AT PO_ITEMP
WHERE HIGH = MYEKPO-EBELN AND LOW = MYEKPO-EBELP.
ENDLOOP.
CHECK SY-SUBRC = 0. "PO/item pair was listed
ENDIF.
* should do authorization checking here **
PERFORM FILL_SUMS.
PERFORM FILL_OUTTAB. "fill info for output
CLEAR OUTTAB.
ENDSELECT.
ENDSELECT.
PERFORM WRITE_OUTTAB.
*---------------------------------------------------------------------*
* FORM FILL_SUMS *
*---------------------------------------------------------------------*
FORM FILL_SUMS. "fill sums table with GR/IR data from ekbe
CLEAR SUMS. CLEAR SUMS[].
SELECT ZEKKN BEWTP MENGE DMBTR SHKZG FROM EKBE INTO SUMS
WHERE EBELN = MYEKPO-EBELN AND EBELP = MYEKPO-EBELP.
CHECK SUMS-SHKZG <> ' '.
IF SUMS-SHKZG = 'H'. "negative value
SUMS-MENGE = - SUMS-MENGE.
SUMS-DMBTR = - SUMS-DMBTR.
ENDIF.
SUMS-SHKZG = ' '.
COLLECT SUMS.
ENDSELECT.
ENDFORM.

*---------------------------------------------------------------------*
* FORM FILL_OUTTAB *
*---------------------------------------------------------------------*
FORM FILL_OUTTAB.
* preconditions: myekpo is set at current PO and item
* sums has gr/ir totals, by zekkn sub-index
CLEAR OUTTAB.
LOOP AT SUMS.
IF SUMS-BEWTP = 'E'. "goods receipt
OUTTAB-GR = OUTTAB-GR + SUMS-MENGE.
OUTTAB-GRVAL = OUTTAB-GRVAL + SUMS-DMBTR.
ELSEIF SUMS-BEWTP = 'R'. "invoice receipt
OUTTAB-IR = OUTTAB-IR + SUMS-MENGE.
OUTTAB-IRVAL = OUTTAB-IRVAL + SUMS-DMBTR.
ELSE.
* perform write_bewtp_unhandled.
ENDIF.
ENDLOOP.
IF COMPARE = SPACE.
CHECK OUTTAB-GR <> OUTTAB-IR. "if gr/ir is equal, stop processing
ELSE. "COMPARE = 'A'.
CHECK ( OUTTAB-IR < OUTTAB-GR OR
( OUTTAB-GR = 0 AND OUTTAB-IR = 0 ) ).
ENDIF.
OUTTAB-EBELN = MYEKPO-EBELN.
OUTTAB-EBELP = MYEKPO-EBELP.
OUTTAB-MENGE = MYEKPO-MENGE.
OUTTAB-TXZ01 = MYEKPO-TXZ01.
OUTTAB-OUT = OUTTAB-GR - OUTTAB-IR.
OUTTAB-OUTVAL = OUTTAB-GRVAL - OUTTAB-IRVAL.
OUTTAB-ESTGRVAL = OUTTAB-GR * MYEKPO-NETPR.
OUTTAB-ESTOUTVAL = OUTTAB-ESTGRVAL - OUTTAB-IRVAL.
IF MYEKPO-KNTTP <> ' '. "account assignment: need to use ekkn
IF EKPO-VRTKZ = '2'. "multiple account distributed by percentage
WRITE: / 'This program does not handle accounts distributed',
'by percentage. Pls check manually (PO number',
EKPO-EBELN, ')'.
EXIT.
ENDIF.
* Fill in random info from ekkn.
SELECT SINGLE MENGE VPROZ SAKTO KOSTL KSTRG FROM EKKN
INTO MYEKKN WHERE
EBELN = MYEKPO-EBELN AND EBELP = MYEKPO-EBELP.
OUTTAB-SAKTO = MYEKKN-SAKTO.
OUTTAB-KOSTL = MYEKKN-KOSTL.
OUTTAB-KSTRG = MYEKKN-KSTRG.
APPEND OUTTAB. CLEAR OUTTAB.
ENDIF. "account assignment
ENDFORM.

*---------------------------------------------------------------------*
* FORM WRITE_OUTTAB *
*---------------------------------------------------------------------*
FORM WRITE_OUTTAB.
DESCRIBE TABLE OUTTAB LINES LN.
IF LN = 0.
WRITE: / 'No records found.'.
EXIT.
ENDIF.
SORT OUTTAB BY SAKTO KOSTL KSTRG.
LOOP AT OUTTAB.
IF ( NOT OLDSAKTO IS INITIAL ) AND OUTTAB-SAKTO <> OLDSAKTO AND
WROTE_SUBT = SPACE.
DO_SUBTOTAL = 'X'.
ENDIF.
OLDSAKTO = OUTTAB-SAKTO.
IF ( NOT OLDKOSTL IS INITIAL ) AND OUTTAB-KOSTL <> OLDKOSTL AND
WROTE_SUBT = SPACE.
DO_SUBTOTAL = 'X'.
ENDIF.
IF ( NOT OLDKSTRG IS INITIAL ) AND OLDKSTRG <> OUTTAB-KSTRG.
DO_SUBTOTAL = 'X'.
ENDIF.
OLDKSTRG = OUTTAB-KSTRG.
WROTE_SUBT = SPACE.
IF DO_SUBTOTAL = 'X'.
PERFORM WRITE_COBJ_SUBTOTAL.
CLEAR COBJ_SUBTOTAL.
DO_SUBTOTAL = SPACE.
ENDIF.
ADD-CORRESPONDING OUTTAB TO COBJ_SUBTOTAL.
ADD-CORRESPONDING OUTTAB TO TOTALS.
IF OUTTAB-OUT < 0.
FORMAT COLOR COL_NEGATIVE.
ENDIF.
WRITE: /
OUTTAB-EBELN UNDER TEXT-004, "PO doc
OUTTAB-EBELP UNDER TEXT-005, "PO item
OUTTAB-SAKTO UNDER TEXT-006, "G/L Acct
OUTTAB-KOSTL UNDER TEXT-007, "Cost Center
OUTTAB-KSTRG UNDER TEXT-008, "Cost Object
(13) OUTTAB-MENGE UNDER TEXT-009, "Quantity
(13) OUTTAB-GR UNDER TEXT-010, "GR quantity
(13) OUTTAB-IR UNDER TEXT-011, "IR quantity
(13) OUTTAB-ESTGRVAL UNDER TEXT-017, "Estimated GR Value
* (13) outtab-grval under text-012, "GR Val
(13) OUTTAB-IRVAL UNDER TEXT-013, "IR Value
(13) OUTTAB-OUT UNDER TEXT-014, "Outstandng IR qty
(13) OUTTAB-ESTOUTVAL UNDER TEXT-018, "Estimated Out IR Value
* (13) outtab-outval under text-015. "Outstandng IRval
OUTTAB-TXZ01 UNDER TEXT-019.
IF COMPARE = 'A'.
LOOP AT PO_AUFNR WHERE HIGH = OUTTAB-EBELN.
WRITE: PO_AUFNR-LOW UNDER TEXT-020.
ENDLOOP.
ENDIF.
FORMAT COLOR OFF.
ENDLOOP.
PERFORM WRITE_COBJ_SUBTOTAL.
PERFORM WRITE_TOTALS.
ENDFORM.

*---------------------------------------------------------------------*
* FORM WRITE_HEADERS *
*---------------------------------------------------------------------*
FORM WRITE_HEADERS.
FORMAT COLOR COL_HEADING.
WRITE: / TEXT-004, "PO
12 TEXT-005, "Item
18 TEXT-006, "G/L
29 TEXT-007, "Cost Center
40 TEXT-008, "Cost Object
49 TEXT-009, "Tot Qty
57 TEXT-010, "GR Qty
71 TEXT-011, "IR Qty
85 TEXT-017, "Est GR Value
* 85 text-012, "GR Val
99 TEXT-013, "IR Val
113 TEXT-014, "Outstanding IR Qty
* 127 text-015. "Outstanding IR Val
127 TEXT-018, "Est Out IR Val
141 TEXT-019. "short text
IF COMPARE = 'A'.
WRITE: 183 TEXT-020. "project
ENDIF.
WRITE: / SY-ULINE.
FORMAT COLOR OFF.
ENDFORM.

TOP-OF-PAGE.
WRITE: SY-DATUM, SY-REPID, '/', SY-UNAME.
IF COMPARE = 'A'. "called from proj exp. report
READ TABLE POSTDAT INDEX 1.
WRITE: 85 'Project Expenditure Tracking Report (By PO Number)'.
WRITE: 'Posting date'.
IF POSTDAT-HIGH IS INITIAL.
WRITE: ':', POSTDAT-LOW.
ELSE.
WRITE: 'Between', POSTDAT-LOW, 'and', POSTDAT-HIGH.
ENDIF.
ELSE.
WRITE: 110 'Outstanding Purchase Order'.
ENDIF.
WRITE: 240 'Page:', 248(2) SY-PAGNO, / SY-ULINE.
PERFORM WRITE_HEADERS.

*&---------------------------------------------------------------------*
*& Form WRITE_COBJ_SUBTOTAL
*&---------------------------------------------------------------------*
FORM WRITE_COBJ_SUBTOTAL.
IF COMPARE = ' '.
WRITE: / SY-ULINE.
WRITE: / 'Subtotal' UNDER TEXT-008,
(13) COBJ_SUBTOTAL-MENGE UNDER TEXT-009, "Quantity
(13) COBJ_SUBTOTAL-GR UNDER TEXT-010, "GR quantity
(13) COBJ_SUBTOTAL-IR UNDER TEXT-011, "IR quantity
(13) COBJ_SUBTOTAL-ESTGRVAL UNDER TEXT-017, "Estimated GR Value
(13) COBJ_SUBTOTAL-IRVAL UNDER TEXT-013, "IR Value
(13) COBJ_SUBTOTAL-OUT UNDER TEXT-014, "Outstandng IR qty
(13) COBJ_SUBTOTAL-ESTOUTVAL UNDER TEXT-018. "Estimated Out IRva
SKIP 1.
WROTE_SUBT = 'X'.
ENDIF.
ENDFORM. " WRITE_COBJ_SUBTOTAL
*&---------------------------------------------------------------------*
*& Form WRITE_TOTALS
*&---------------------------------------------------------------------*
FORM WRITE_TOTALS.
WRITE: / SY-ULINE.
WRITE: / 'Total:' UNDER TEXT-008,
(13) TOTALS-MENGE UNDER TEXT-009, "Quantity
(13) TOTALS-GR UNDER TEXT-010, "GR quantity
(13) TOTALS-IR UNDER TEXT-011, "IR quantity
(13) TOTALS-ESTGRVAL UNDER TEXT-017, "Estimated GR Value
(13) TOTALS-IRVAL UNDER TEXT-013, "IR Value
(13) TOTALS-OUT UNDER TEXT-014, "Outstandng IR qty
(13) TOTALS-ESTOUTVAL UNDER TEXT-018. "Estimated Out IRva
ENDFORM. " WRITE_TOTALS

SAP ABAP/4 Program:Un/Lock all users in a client

Sometimes it is useful to be able to lock all the users out of a client; for instance, during a client copy (you can also do this with tp locksys, but you have to issue that command from the OS level, and then you can only use DDIC or SAP* to log on). You can use this program to lock out all users except yourself.

This program (un)locks all the users in a client, except for the current user, and the SAP* user. You might want to add somthing like SELECT-OPTIONS EXEMPTUS FOR USR02-BNAME to allow a list of usernames not to be processed.

Un/Lock all users in a client

*&---------------------------------------------------------------------*
*& Report YUSRLOCK *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT YUSRLOCK MESSAGE-ID Z1 .
TABLES: USR02.
PARAMETERS: LOCK AS CHECKBOX, LISTLOCK AS CHECKBOX.
DATA: UFLAGVAL TYPE I, LOCKSTRING(8) TYPE C.

*-------------- Authorization check -----------------------*
AUTHORITY-CHECK OBJECT 'ZPROG_RUN' ID 'PROGRAM' FIELD SY-CPROG.
IF SY-SUBRC <> 0.
IF SY-SUBRC = 4.
MESSAGE E000 WITH SY-CPROG. "some message about authorization check failure
ELSE.
MESSAGE E005 WITH SY-SUBRC. "some message about authorization check failure
ENDIF.
ENDIF.

IF LISTLOCK = 'X'.
WRITE:/ 'List all locked users: '.
SELECT * FROM USR02 WHERE UFLAG = 64.
WRITE: / USR02-BNAME.
ENDSELECT.
EXIT.
ENDIF.
IF LOCK = 'X'.
UFLAGVAL = 64. "lock all users
LOCKSTRING = 'locked'.
ELSE.
UFLAGVAL = 0. "unlock all users
LOCKSTRING = 'unlocked'.
ENDIF.

SELECT * FROM USR02 WHERE BNAME <> 'SAP*' AND BNAME <> SY-UNAME.
IF USR02-UFLAG <> 0 AND USR02-UFLAG <> 64.
WRITE: 'User', USR02-BNAME, 'untouched; please handle manually.'.
CONTINUE.
ENDIF.

** check that user has authority to make these changes
AUTHORITY-CHECK OBJECT 'S_USER_GRP'
ID 'CLASS' FIELD USR02-CLASS
ID 'ACTVT' FIELD '05'.
IF SY-SUBRC <> 0.
IF SY-SUBRC = 4.
WRITE: /'You are not authorized to lock/unlock user ',
USR02-BNAME, USR02-CLASS.
ELSE.
WRITE: /'Authorization error checking user ',
USR02-BNAME, USR02-CLASS, '(return code', SY-SUBRC, ').'.
ENDIF.
ELSE. "has authority
UPDATE USR02 SET UFLAG = UFLAGVAL WHERE BNAME = USR02-BNAME.
WRITE: / 'User', USR02-BNAME, LOCKSTRING, '.'.
ENDIF.

SAP ABAP/4 Program: Output Table Fields to a List

When you're looking at the structure of a table, SAP will let you print the structure, but it won't let you save the structure. This can be annoying. This report outputs the table structure to a list. At this point the user can use the System->List->Save->Local file command to save the list to a file.

Output Table Fields to a List


*&---------------------------------------------------------------------*
*& Report YTABFLDS *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT YTABFLDS .
TABLES: DD02L, DD03L, DD04T.

PARAMETERS THETABLE LIKE DD02L-TABNAME OBLIGATORY.
DATA: BEGIN OF MYTABLE,
TABNAME LIKE DD02L-TABNAME,
AS4LOCAL LIKE DD02L-AS4LOCAL,
AS4VERS LIKE DD02L-AS4VERS,
END OF MYTABLE.

SELECT SINGLE TABNAME AS4LOCAL AS4VERS INTO MYTABLE FROM DD03L
WHERE TABNAME = THETABLE.
WRITE: / MYTABLE-TABNAME, 11 MYTABLE-AS4LOCAL, 13 MYTABLE-AS4VERS.
SELECT * FROM DD03L
WHERE TABNAME = MYTABLE-TABNAME AND
AS4LOCAL = MYTABLE-AS4LOCAL AND AS4VERS = MYTABLE-AS4VERS.
WRITE: / DD03L-FIELDNAME, 11 DD03L-KEYFLAG, 13 DD03L-ROLLNAME,
24 DD03L-CHECKTABLE, 35 DD03L-INTTYPE, 37 DD03L-REFTABLE,
48 DD03L-DATATYPE.
SELECT SINGLE * FROM DD04T
WHERE ROLLNAME = DD03L-ROLLNAME AND
AS4LOCAL = MYTABLE-AS4LOCAL AND AS4VERS = MYTABLE-AS4VERS AND
DDLANGUAGE = 'E'.

WRITE: 53 DD04T-DDTEXT.
ENDSELECT.

SAP ABAP Program: Output of Date Format

Suppose a date is given in the format 20050428 how to get the output in the format 28th Apr 2005.

FORM set_text_date.

DATA: month(9),
year(4),
date(2).

CASE p_frd+4(2).

WHEN '01'.
month = 'January'.

WHEN '02'.
month = 'February'.

WHEN '03'.
month = 'March'.

WHEN '04'.
month = 'April'.

WHEN '05'.
month = 'May'.

WHEN '06'.
month = 'June'.

WHEN '07'.
month = 'July'.

WHEN '08'.
month = 'August'.

WHEN '09'.
month = 'September'.

WHEN '10'.
month = 'October'.

WHEN '11'.
month = 'November'.

WHEN '12'.
month = 'December'.

WHEN OTHERS.

ENDCASE.

WRITE p_frd+0(4) TO year.

WRITE p_frd+6(2) TO date.

CONCATENATE month date ',' year INTO return_date SEPARATED BY space.

CONDENSE return_date.

ENDFORM.

ABAP Tips by : Kiran

Currently my date is getting printed in format 05262005.
I want the output as 26 May, 2005.
I have tried using Set date mask option but it is not picking up in the output.

Code:

This code yields as 12 march 2006.

DATA: ZTEMP(9).

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
EXPORTING
INPUT = IS_DLV_DELNOTE-HD_GEN-CREA_DATE
IMPORTING
OUTPUT = ZTEMP.

ZDD = ZTEMP+3(2).
ZMMM = ZTEMP+0(3).
ZYYYY = ZTEMP+5(4).

SAP ABAP Programming Language

Typen und Objekte

This graphic is explained in the accompanying text




ABAP Syntax

Basic Statements

Processing Large Volumes of Data

Saving Data Externally

Modularization Techniques

Special Techniques

SAP ABAP Sample Test Questions on Programming

#1. What are the 2 boxes in your system for coding for Abap and their logins?

Development System & IDES/Sandbox

# 2. If I get a problem on a report in Production server how can I modify the report.

If the problem in production server we have to alter the program in Developemnt Client and transport it to QA client Test it throughly and then Transport it to Production.

# 3. Tell me about Tokens.

Tokens are Issues sent by the Client to us.

#4 .How to Fix the bugs and where you will do those things.

It Actuall Depends what kind of bugs they asked about:
If it is a problem in Program, then we alter them in the SE38 (Develpment) and transport it after testing to Prd Server.

#5. What is a sandboxes.

SAND BOX is nothing but a test client other than Develpment Client or QA.

#6.How to conncet the from ur office to clinet in US.

It will be configured by the BASIS guys..

In the sap logon pad they will enter the application server id and Routing String and the SERver type in the Sytem Number....
with that we will connect

#7.Tell me about VPN and the connections.

Its a another way to connect to other PC. its a 3rd party utility....

#8. How to login ur system.

Thru SAP Logon enter the client number ,user id & password.

#9 .What is the purpose of SE14.

Database Utility to perform table maintenance such as deleting the table or adjusting the table when there is a structure change.

#10 .What is the purpose of SM30.

SM30 is a table Maintanance for the Ztable Created by us.

#11.In Data dictionary in the table creation,What is the purpose of Technical settings.

To identify the Size of the Table Created and to Set whether buffering needs to be done for the table or not.

#12. What is the purpose of buffering in technical settings and for what type of tables are using buffering.

It will reduce the Network tarffic but disadvantage is it will not update the Server back immediately.

#13. In reporting tell me all the events in a sequentail order.

- Initialization.
- At Selection-Screen
- Start-of-Selection.
- Top-of-Page.
- At Pfn.
- End-of-Page.
- End-of-Selection.

SAP ABAP Programming Documentation

This documentation describes how to write application programs within the three-tier client/server architecture of the R/3 System.

This graphic is explained in the accompanying text

R/3 applications are written in the ABAP programming language, and run within the application layer of the R/3 System.

ABAP programs communicate with the database management system of the central relational database (RDBMS), and with the graphical user interface (SAPgui) at presentation level.

Contents

The documentation is divided into five sections:

Introduction to ABAP

This contains the basics of application programming in the R/3 System. This information is essential for an understanding of ABAP programming. Following an overview of the R/3 Basis system, it introduces the essential features of application programs and the ABAP programming language. Finally, it gives a short introduction to how you can create an application program in the ABAP Workbench.

The ABAP Programming Language

This section describes the statements in the ABAP programming language. Beginning with simple statements for data declarations, data processing, and program flow control, it progresses to topics such as modularization and special techniques, explaining which ABAP statements can be used for which purposes.

ABAP User Dialogs

The different screens that can belong to ABAP programs are displayed here. This shows how you can program and control interaction between ABAP programs and users in the form of screens.

Running ABAP Programs

This section explains how ABAP programs are executed in the R/3 System. It shows how you can start programs, the conditions under which you must start them, and the different kinds of program execution.

ABAP Database Access

This section explains how to work with the database in the R/3 System. It describes the parts of the programming language that are converted into SQL statements in the database, and shows how you can program database updates.

ABAP Objects

This is an introduction to ABAP Objects, the object-oriented extension of ABAP. Objects, classes and interfaces are introduced as the basic elements of ABAP objects. It shows how classes can be defined independently using interfaces or inheritance. It then goes on to introduce further components of classes, namely methods and events.

ABAP and JavaScript

The section describes how to link JavaScript programs in ABAP using class CL_JAVA_SCRIPT.

Appendix

The appendix contains summary descriptions and overviews, including a list of all system fields, an ABAP statement reference and a glossary.

Sample Programs

Note that the sample programs in this documentation can be used for testing purposes in every R/3 System starting with Release 4.5. They can be found in Transaction ABAPDOCU . The program structure corresponds to that of this documentation.

Further Reading

SAP Style Guide

Structure link Changing the SAP Standard

Structure link ABAP Workbench: Tools

Structure link ABAP Dictionary

Structure link Remote Communications

Structure link RFC Programming in ABAP

Structure link ABAP as an OLE Automation Controller

Structure link Basis Programming Interfaces

Structure link ABAP Query

Archives