Professional Documents
Culture Documents
Answer:: A: A Selection Text. B: A Basic List Row. C: A Page Footer
Answer:: A: A Selection Text. B: A Basic List Row. C: A Page Footer
Answer:
A. SY-SUBRC=4. CONT='C'. FLAG=''.
B. SY-SUBRC=0. CONT='C'. FLAG=''.
C. SY-SUBRC=0. CONT=''. FLAG=''.
Question:
The structure of a table has been changed in the ABAP/4 Dictionary.
Which of the following adjustments in the relevant database table is correct, if you
want to retain the previous data?
Answer:
A. Delete and recreate the database table.
B. Change the database directory (ALTER TABLE) where the structure change
with ALTER TABLE is supported by the database.
C. Convert the table.
Question:
Must Exits be predefined by SAP programmers?
Answer:
A. No
B. Yes
C. Customers can determine for themselves where they want to use exits
REPORT Z_LIST_MATERIALS.
TYPE-POOLS: SLIS.
TABLES:MARC, MARD, VBAP, LIPS, EKPO, VBFA, EKBE, MARM, VBBE, MARA, MBEW.
SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_WERKS FOR MARC-WERKS, " Plant
S_MATNR FOR MARC-MATNR, " Material
S_MTART FOR MARA-MTART. " Material Type SELECTION-SCREEN
END OF BLOCK SEL.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT. " ALV Variant
CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
DATA: BEGIN OF INV OCCURS 100,
WERKS LIKE MARD-WERKS, "
MATNR LIKE MARD-MATNR, "
MTART LIKE MARA-MTART, "
STPRS LIKE MBEW-STPRS, "
AVAIL LIKE MARD-LABST, "
LABST LIKE MARD-LABST, "
INSME LIKE MARD-INSME, "
RETME LIKE MARD-RETME, "
TRANS LIKE MARC-UMLMC, "
UMLMC LIKE MARC-UMLMC, "
UMLME LIKE MARD-UMLME, "
Plant
Material
Material Type
Standard Price
Available
Unrestricted use
Quality Inspection
Returns
Stock in transit (calculated)
Stock Transfer (plant)
Transfer (SLoc)
GR Blocked Stock
Stock in transit
Blocked
" Sales orders
Scheduled for Delivery
Open Purch. Orders
Stock Value (Calculated)
Unit of measure
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME
L_FIELDCAT-SP_GROUP
L_FIELDCAT-NO_OUT
L_FIELDCAT-FIELDNAME
APPEND L_FIELDCAT TO
L_FIELDCAT-FIELDNAME
APPEND L_FIELDCAT TO
L_FIELDCAT-FIELDNAME
APPEND L_FIELDCAT TO
L_FIELDCAT-FIELDNAME
APPEND L_FIELDCAT TO
L_FIELDCAT-FIELDNAME
APPEND L_FIELDCAT TO
ENDFORM.
= 'INV'.
= 'A'.
= 'X'.
= 'MEINS'.
P_FIELDTAB.
= 'UMLMC'.
P_FIELDTAB.
= 'TRAME'.
P_FIELDTAB.
= 'STPRS'.
P_FIELDTAB.
= 'VALUE'.
P_FIELDTAB.
" INITIALIZE_FIELDCAT
*&---------------------------------------------------------------------*
*&
Form BUILD_EVENTTAB
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_EVENTS[] text
*
*----------------------------------------------------------------------*
FORM BUILD_EVENTTAB USING P_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS
= P_EVENTS.
READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO P_EVENTS.
ENDIF.
ENDFORM.
" BUILD_EVENTTAB
*&---------------------------------------------------------------------*
*&
Form BUILD_COMMENT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_HEADING[] text
*
*----------------------------------------------------------------------*
FORM BUILD_COMMENT USING P_HEADING TYPE SLIS_T_LISTHEADER.
DATA: HLINE TYPE SLIS_LISTHEADER,
TEXT(60) TYPE C,
SEP(20) TYPE C.
CLEAR: HLINE, TEXT.
HLINE-TYP = 'H'.
WRITE: TEXT-101 TO TEXT+23.
HLINE-INFO = TEXT.
APPEND HLINE TO P_HEADING.
CLEAR TEXT.
WRITE: 'User: ' TO TEXT,
SY-UNAME TO TEXT+6,
ENDFORM.
" BUILD_COMMENT
*---------------------------------------------------------------------*
*
FORM TOP_OF_PAGE
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEADING.
ENDFORM.
*&---------------------------------------------------------------------*
*&
Form INITIALIZE_VARIANT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM INITIALIZE_VARIANT.
G_SAVE = 'A'.
CLEAR G_VARIANT.
G_VARIANT-REPORT = REPNAME.
GX_VARIANT = G_VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE
= G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 0.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
ENDFORM.
" INITIALIZE_VARIANT
*&---------------------------------------------------------------------*
*&
Form F4_FOR_VARIANT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM F4_FOR_VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = G_VARIANT
I_SAVE
= G_SAVE
IMPORTING
E_EXIT
= G_EXIT
ES_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 2.
MESSAGE ID SY-MSGID TYPE 'S'
NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF G_EXIT = SPACE.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
ENDIF.
ENDFORM.
" F4_FOR_VARIANT
*&---------------------------------------------------------------------*
*&
Form PAI_OF_SELECTION_SCREEN
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM PAI_OF_SELECTION_SCREEN.
*
IF NOT P_VARI IS INITIAL.
MOVE G_VARIANT TO GX_VARIANT.
MOVE P_VARI TO GX_VARIANT-VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE
= G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT.
G_VARIANT = GX_VARIANT.
ELSE.
PERFORM INITIALIZE_VARIANT.
ENDIF.
ENDFORM.
" PAI_OF_SELECTION_SCREEN
*&---------------------------------------------------------------------*
*&
Form GET_MARD
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_MARD.
SELECT MATNR WERKS LABST INSME RETME UMLME SPEME
FROM MARD
INTO CORRESPONDING FIELDS OF INV
WHERE MATNR IN S_MATNR
AND
WERKS IN S_WERKS.
COLLECT INV.
ENDSELECT.
PERFORM FILTER_BY_MATERIAL_TYPE.
ENDFORM.
" GET_MARD
*&---------------------------------------------------------------------*
*&
Form FILTER_BY_MATERIAL_TYPE
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM FILTER_BY_MATERIAL_TYPE.
LOOP AT INV.
CLEAR INV-MTART.
" GET_UNIT_OF_MEASURE
*&---------------------------------------------------------------------*
*&
Form GET_OPEN
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_OPEN.
DATA: BEGIN OF XTAB OCCURS 10,
" Open orders table
WERKS LIKE EKPO-WERKS,
LGORT LIKE EKPO-LGORT,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MENGK LIKE EKPO-MENGE,
END OF XTAB.
RANGES: L_WERKS FOR MARD-WERKS.
LOOP AT INV.
REFRESH XTAB.
CLEAR: XTAB, L_WERKS.
MOVE INV-WERKS TO L_WERKS-LOW.
CALL FUNCTION 'MB_ADD_PURCHASE_ORDER_QUANTITY'
EXPORTING
X_MATNR = INV-MATNR
X_MEINS = INV-MEINS
X_ELIKZ = SPACE
X_LOEKZ = SPACE
TABLES
XTAB
= XTAB
XWERKS = L_WERKS.
MOVE XTAB-MENGE TO INV-MENGE.
MODIFY INV.
ENDLOOP.
ENDFORM.
" GET_OPEN
*&---------------------------------------------------------------------*
*&
Form GET_PRICE
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM GET_PRICE.
LOOP AT INV.
SELECT SINGLE STPRS
FROM MBEW
INTO INV-STPRS
WHERE MATNR EQ INV-MATNR
AND
BWKEY EQ INV-WERKS
AND
BWTAR EQ SPACE.
IF SY-SUBRC EQ 0.
INV-VALUE = INV-STPRS *
( INV-LABST + INV-INSME + INV-TRANS + INV-SPEME ).
MODIFY INV.
ENDIF.
ENDLOOP.
ENDFORM.
" GET_PRICE
*---------------------------------------------------------------------*
*
FORM CONVERT_UNIT_OF_MEASURE
*
*---------------------------------------------------------------------*
*
text
*
*---------------------------------------------------------------------*
* --> P_MATNR
*
* --> P_VRKME
*
* --> P_QUANT
*
*---------------------------------------------------------------------*
FORM CONVERT_UNIT_OF_MEASURE USING P_MATNR P_VRKME P_QUANT.
DATA: UMREZ LIKE MARM-UMREZ,
UMREN LIKE MARM-UMREN.
SELECT SINGLE UMREZ UMREN
INTO (UMREZ, UMREN)
FROM MARM
WHERE MATNR EQ P_MATNR
AND
MEINH EQ P_VRKME.
IF SY-SUBRC EQ 0.
COMPUTE P_QUANT = ( P_QUANT * UMREZ ) / UMREN.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&
Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_LAYOUT text
*
*----------------------------------------------------------------------*
FORM BUILD_LAYOUT USING P_LAYOUT TYPE SLIS_LAYOUT_ALV.
P_LAYOUT-F2CODE
= F2CODE.
P_LAYOUT-ZEBRA
= 'X'.
P_LAYOUT-DETAIL_POPUP = 'X'.
ENDFORM.
" BUILD_LAYOUT
*&---------------------------------------------------------------------*
*&
Form WRITE_OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM WRITE_OUTPUT.
SORT INV BY WERKS MATNR.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= REPNAME
I_INTERNAL_TABNAME = 'INV'
I_INCLNAME
= REPNAME
CHANGING
CT_FIELDCAT
= FIELDTAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPNAME
I_STRUCTURE_NAME
= 'INV'
IS_LAYOUT
= LAYOUT
IT_FIELDCAT
= FIELDTAB
I_DEFAULT
= 'A'
I_SAVE
= G_SAVE
IS_VARIANT
= G_VARIANT
IT_EVENTS
= EVENTS[]
TABLES
T_OUTTAB
= INV.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
ENDFORM.
" WRITE_OUTPUT
ENDIF.
2) Normally we call them as Program symbols. Those are defined in Driver program.
We can use in Script as for exp. &itab-matnr&
Other variables ---System symbols : ex &page&
---Std symbols :
---Text symbols :We define them in script editor itself.
Ex : /: Define &mysymbol& = 'XX'
3) We can control the tab feed in a paragraph with tab positions. The tab stops us define
in the paragraph format replace the tab spacing we defined in the header data of the form.
However, this depends on the extent to which we have defined tab stops in the paragraph
format. If there are fewer tabs in the paragraph formats than in the header data, the tab
stops of the header data are used for the rest of the line.
SAPscripts Tips by : Venkat O
Q: We get the total number of pages as expected by using 'SAPSCRIPTFORMPAGES' in a duplex layout. In our case duplex case is always 'Terms &
Conditions'. We do not want the number of pages as in duplex printing. What is the
best possible solution?
A: On the Terms & Conditions page, Change the Page counter mode to 'HOLD' to keep
the page counter from incrementing when you print the Term & Conditions.
Q: Can I Print a logo on an Invoice?
A: Save a Logo using Paintshop Pro or Corel Draw as Tiff file. Use RSTXLDMC to
convert the logo to standard text in SapScript. When the program is executed, the path
and file name have to be correctly specified.
Process could be like the following:
Run RSTXLDMC
Enter file name C:\MAIL\COMPLOGO.TIF
Resolution for Tiff file
Absolute X-position
Absolute Y-position
Absolute positioning
Reserved height
Shift to right
UOM = CM
Text title
Line width for text = 132
Text name ZHEX-MACRO-COMPLOGO
Text ID ST
Text language = E
Postscript scaling
Width & Height according to PS scaling
SY-TIMLO
Users local time, for example 154353, 225312,
SY-TZONE
Time difference in seconds between local time and Greenwich Mean Time (UTC), for
example,
360, 10800.
SY-UZEIT
Current application server time. for example 164353, 215312,
SY-ZONLO
Users time zone, for example, EST, UTC,
SY-BATCH
X if the ABAP program is running in the background, otherwise space
Batch Input
SY-BINPT
X while a batch input session is running and when an ABAP program is called using
CALL TRANSACTION USING, otherwise space.
OPTIONS FROM in the CALL TRANSACTION USING statement can set SYBINPT to space either for
the entire duration of the program, or at the end of the BDC data.
SY-BINPT is always space during a CATT procedure.
SY-TABIX
Current line of an internal table. SY-TABIX is set by the statements below, but only for
index tables. The field is either not set or is set to 0 for hashed tables.
APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the
overall number of entries in the table.
COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the
table has the type HASHED TABLE, SY-TABIX is set to 0.
LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop
lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the
loop. It is set to 0 if the table has the type HASHED TABLE.
READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary
search, and the system does not find a line, SY-TABIX contains the total number of lines,
or one more than the total number of lines. SY-INDEX is undefined if a linear search fails
to return an entry.
SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search
string is found.
SY-TFILL
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL
contains the number of lines in the relevant internal table.
SY-TLENG
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG
contains the length of the lines in the relevant internal table.
SY-TOCCU
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG
contains the initial amount of memory allocated to the relevant internal table.
name2 = text-n02.
name3 = text-n03.
REPORT ZSUBSCREEN.
TABLES: USR02,
"Logon data
SSCRFIELDS. "FIELDS ON SELECTION SCREENS
*--------------------------------------------------------------* SUBSCREEN 1
*--------------------------------------------------------------SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-010.
SELECT-OPTIONS: USERNAME FOR USR02-BNAME.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN 100.
*--------------------------------------------------------------* SUBSCREEN 2
*--------------------------------------------------------------SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-020.
SELECT-OPTIONS: LASTLOGI FOR USR02-TRDAT.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN END OF SCREEN 200.
*--------------------------------------------------------------* SUBSCREEN 3
*--------------------------------------------------------------SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-030.
SELECT-OPTIONS: CLASSTYP FOR USR02-CLASS.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN END OF SCREEN 300.
* STANDARD SELECTION SCREEN FOR SCROLLING LEFT AND RIGHT
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK SUB FOR 15 LINES,
END OF BLOCK SUB.
START-OF-SELECTION.
SELECT * FROM USR02 WHERE BNAME IN USERNAME
AND ERDAT IN LASTLOGI
AND CLASS IN CLASSTYP.
WRITE: / 'User ', USR02-BNAME,
'Last Login Date ', USR02-TRDAT,
'Last Login Time ', USR02-LTIME,
'CLASS ', USR02-CLASS.
ENDSELECT.
END-OF-SELECTION.
INITIALIZATION.
* SCREEN ICON LEFT AND RIGHT
SSCRFIELDS-FUNCTXT_01 = '@0D@'.
SSCRFIELDS-FUNCTXT_02 = '@0E@'.
SUB-PROG = SY-REPID.
SUB-DYNNR = 100.
AT SELECTION-SCREEN.
CASE SY-DYNNR.
WHEN 100.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = 300.
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 200.
ENDIF.
WHEN 200.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = 100.
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 300.
ENDIF.
WHEN 300.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = 200.
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 100.
ENDIF.
ENDCASE.