工作生活与爱好

工作中的记录; 生活中的记忆; 业余爱好的记载。

2007-01-14

 

如何提高ABAP性能

1、使用where语句
不推荐
Select * from zflight.
Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
Endselect.
推荐
Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
Endselect.

2、使用聚合函数
不推荐
Maxnu = 0.
Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Endselect.
推荐
Select max( fligh ) from zflight into maxnu where airln = ‘LF’ and cntry = ‘IN’.

3、使用视图代替基本表查询
不推荐
Select * from zcntry where cntry like ‘IN%’.
Select single * from zflight where cntry = zcntry-cntry and airln = ‘LF’.
Endselect.
推荐
Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
Endselect.

4、使用INTO table 代替select endselect
不推荐
Refresh: int_fligh.
Select * from zflight into int_fligh.
Append int_fligh. Clear int_fligh.
Endselect.
推荐
Refresh: int_fligh.
Select * from zflight into table int_fligh.

5、使用批量修改内表代替逐行修改
不推荐
Loop at int_fligh.
If int_fligh-flag is initial.
Int_fligh-flag = ‘X’.
Endif.
Modify int_fligh.
Endloop.
推荐
Int_fligh-flag = ‘X’.
Modify int_fligh transporting flag where flag is initial.

6、使用二分法查询,提高查询内表数据速度
不推荐
Read table int_fligh with key airln = ‘LF’.
推荐
Read table int_fligh with key airln = ‘LF’ binary search.

7、两个内表添加使用批量增加代替逐行
不推荐
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Endloop.
推荐
Append lines of int_fligh1 to int_fligh2.

8、使用table buffering
Use of buffered tables is recommended to improve the performance considerably. The buffer is bypassed while using the following statementsSelect distinct
Select … for update
Order by, group by, having clause
Joins
Use the Bypass buffer addition to the select clause in order to explicitly bypass the buffer while selecting the data.

9、 使用FOR ALL Entries
不推荐
Loop at int_cntry. Select single * from zfligh into int_fligh where cntry = int_cntry-cntry. Append int_fligh. Endloop.
推荐
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.

10、正确地使用where语句,使查询能使用索引
When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index
To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. One more tip is that if a table begins with MANDT, while an index does not, there is a high possibility that the optimizer might not use that index.

11、正确地使用MOVE语句
Instead of using the move-corresponding clause it is advisable to use the move statement instead. Attempt should be made to move entire internal table headers in a single shot, rather than moving the fields one by one.

12、正确地使用inner join
Let us take an example of 2 tables, zairln and zflight. The table zairln has the field airln, which is the airline code and the field lnnam, which is the name of the airline. The table zflight has the field airln, the airline code and other fields which hold the details of the flights that an airline operates.
Since these 2 tables a re logically joined by the airln field, it is advisable to use the inner join.
Select a~airln a~lnnam b~fligh b~cntry into table int_airdet
From zairln as a inner join zflight as b on a~airln = b~airln.
In order to restrict the data as per the selection criteria, a where clause can be added to the above inner join.

13、使用sort by 代替order by

14、避免使用SELECT DISTINCT语句
使用的 ABAP SORT + DELETE ADJACENT DUPLICATES 代替.


FOR ALL ENTRIES的表超过1000行了,效率就低了。


 

下载/上传 Smart Forms 和 Smart Styles的程序

由于本人的版本的是4.6C的,SAP没有提供下载和上传Smart Forms和Smart Styles的功能,幸运的是在网上找到了一个能实现这种功能的程序,如有需要可以下载。
本人已经修改了程序中存在的一些BUG,但也许还存在一些,如果大家有兴趣的话可以继续完善之,共同提高!


REPORT ZQUALITY LINE-SIZE 150 NO STANDARD PAGE HEADING.
******************************************************
*Program : ZSMART_FORM_UPLOAD_DOWNLOAD *
*Description : This utility/tool can download or *
* upload smartform and smartstyles. *
*====================================================*

*&===== TABLES =====
TABLES: STXFADM,"SAPscript Smart Forms: Administration
STXSADM."SAPscript Smart Styles: Administration
DATA: V_PASS,
G_ANS,
BEGIN OF TAB OCCURS 0,
LINE(144),
END OF TAB,
TNAME LIKE SY-REPID.

*&===== SELCTION SCREEN =====
SELECTION-SCREEN BEGIN OF BLOCK SMART1 WITH FRAME TITLE TEXT001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT101."Smart Form Name
PARAMETERS: P_FNAME LIKE STXFADM-FORMNAME DEFAULT 'ZTEST'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT102. "File Name
PARAMETERS: P_FFILE LIKE RLGRAP-FILENAME LOWER CASE
DEFAULT 'C:\ZTEST'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK IND1 WITH FRAME TITLE TEXT002.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT103."None
PARAMETERS: P_FT RADIOBUTTON GROUP ABH1."Form Treatment
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT104."Upload
PARAMETERS: P_FU RADIOBUTTON GROUP ABH1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT105."Download
PARAMETERS: P_FD RADIOBUTTON GROUP ABH1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK IND1.
SELECTION-SCREEN END OF BLOCK SMART1.

SELECTION-SCREEN SKIP 2.

SELECTION-SCREEN BEGIN OF BLOCK SMART2 WITH FRAME TITLE TEXT003.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT106."Smart Style Name
PARAMETERS: P_SNAME LIKE STXFADM-FORMNAME DEFAULT 'ZTEST'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT107."File Name
PARAMETERS: P_SFILE LIKE RLGRAP-FILENAME LOWER CASE
DEFAULT 'C:\ZTEST'."Style File Name
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK IND2 WITH FRAME TITLE TEXT004.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT108."None
PARAMETERS: P_ST RADIOBUTTON GROUP ABH2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT109."Upload
PARAMETERS: P_SU RADIOBUTTON GROUP ABH2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT110."Download
PARAMETERS: P_SD RADIOBUTTON GROUP ABH2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK IND2.
SELECTION-SCREEN END OF BLOCK SMART2.

*&===== INITIALIZATION =====
INITIALIZATION.
TEXT001 = 'Smart Forms Upload/Download'.
TEXT002 = 'Options'.
TEXT003 = 'Smart Style Upload/Download'.
TEXT004 = TEXT002.
TEXT101 = 'Smart Form Name'.
TEXT102 = 'File Name'.
TEXT103 = 'None'.
TEXT104 = 'Upload'.
TEXT105 = 'Download'.
TEXT106 = 'Smart Style Name'.
TEXT107 = TEXT102.
TEXT108 = TEXT103.
TEXT109 = TEXT104.
TEXT110 = TEXT105.

*&===== AT-SELCTION-SCREEN =====
AT SELECTION-SCREEN.
PERFORM SUB_VALIDATION.

DEFINE VMESS.
IF V_PASS = SPACE.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
TITEL = 'Smartform/Smartstyle Upload-Download Utility'
TEXTLINE1 = &1
START_COLUMN = 25
START_ROW = 6.
V_PASS = 'X'.
ENDIF.
END-OF-DEFINITION.

DEFINE ABHISHEK.
TAB-LINE = &1.
TRANSLATE TAB-LINE USING '@B`I!J~N^O%T#F?S|Q'.
APPEND TAB.
CLEAR TAB.
END-OF-DEFINITION.

DEFINE APP.
ITAB-ID = &1. ITAB-KEY = &2. ITAB-ENTRY = &3.
APPEND ITAB.
CLEAR ITAB.
END-OF-DEFINITION.

*&===== START-SELCTION-SCREEN =====
START-OF-SELECTION.
DATA: ERROR(150).
IF V_PASS = SPACE.
PERFORM SUB_WARNING.
IF G_ANS = '1'.
REFRESH TAB. CLEAR: TAB, TNAME.
ABHISHEK: 'PROGRAM ztabhi.'.
PERFORM FORM100000.
PERFORM FORM100001.
PERFORM FORM100002.
PERFORM FORM100003.
PERFORM FORM100004.
PERFORM FORM100005.
* LOOP AT TAB.
* WRITE:/ TAB-LINE.
* ENDLOOP.
GENERATE SUBROUTINE POOL TAB NAME TNAME MESSAGE ERROR.
IF SY-SUBRC = 0.
IF P_FU = 'X'.
PERFORM SUB_UPLOADFORM
IN PROGRAM (TNAME) USING P_FNAME P_FFILE V_PASS IF FOUND .
* PERFORM SUB_UPLOADFORM
* IN PROGRAM ZTABHI USING P_FNAME P_FFILE V_PASS IF FOUND .
ELSEIF P_FD = 'X'.
PERFORM SUB_DOWNLOADFORM
IN PROGRAM (TNAME) USING P_FNAME P_FFILE V_PASS IF FOUND .
* PERFORM SUB_DOWNLOADFORM
* IN PROGRAM ZTABHI USING P_FNAME P_FFILE V_PASS IF FOUND .
ENDIF.
IF P_SU = 'X'.
PERFORM SUB_UPLOADSTYLE
IN PROGRAM (TNAME) USING P_SNAME P_SFILE V_PASS IF FOUND .
ELSEIF P_SD = 'X'.
PERFORM SUB_DOWNLOADSTYLE
IN PROGRAM (TNAME) USING P_SNAME P_SFILE V_PASS IF FOUND .
ENDIF.
ELSE.
VMESS 'ERROR: Either the key is wrong or Program has been modified'.
ENDIF.
ELSE.
VMESS 'Action Cancelled'.
ENDIF.
ENDIF.

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

*& Form form100001
*&---------------------------------------------------------------------*

FORM FORM100001.
ABHISHEK:
' DEFINE DATADECS.',
' DATA: BEGIN OF T_&1 OCCURS 0.',
' INCLUDE STRUCTURE &1.',
' DATA: END OF T_&1.',
' SELECT * INTO TABLE T_&1 FROM &1 WHERE STYLENAME = P_?NAME.',
' END-OF-DEFINITION.',

' DEFINE DOWNLOADALL.',
' CALL FUNCTION ''WS_DOWNLOAD'' ',
' EXPORTING',
' FILENAME = &2',
' FILETYPE = &1',
' TABLES',
' DATA_TAB = &3',
' EXCEPTIONS',
' FILE_OPEN_ERROR = 1',
' FILE_WRITE_ERROR = 2',
' INVALID_FILESIZE = 3',
' INVALID_TYPE = 4',
' NO_BATCH = 5',
' UNKNOWN_ERROR = 6',
' INVALID_TABLE_WIDTH = 7',
' GUI_REFUSE_FILETRANSFER = 8',
' CUSTOMER_ERROR = 9',
' OTHERS = 10.',
' END-OF-DEFINITION.',

' DEFINE UPLOADALL.',
' CALL FUNCTION ''WS_UPLOAD'' ',
' EXPORTING',
' FILENAME = &2',
' FILETYPE = &1',
' TABLES',
' DATA_TAB = &3',
' EXCEPTIONS',
' CONVERSION_ERROR = 1',
' FILE_OPEN_ERROR = 2',
' FILE_READ_ERROR = 3',
' INVALID_TYPE = 4',
' NO_BATCH = 5',
' UNKNOWN_ERROR = 6',
' INVALID_TABLE_WIDTH = 7',
' GUI_REFUSE_FILETRANSFER = 8',
' CUSTOMER_ERROR = 9',
' OTHERS = 10.',
' END-OF-DEFINITION.',

' DEFINE ABHI_SPEC1.',
' DATA: BEGIN OF T_&1 .',
' INCLUDE STRUCTURE &1.',
' DATA: END OF T_&1.',
' CLEAR: L_CHAR, L_NO.',
' LOOP AT %_%A@ WHERE NAME = ''&1''.',
' L_NO = 0.',
' SELECT * FROM DD03L WHERE TABNAME = %_%A@-NAME ORDER BY POSITION .',
' IF DD03L-INTTYPE <> SPACE.',
' IF DD03L-INTTYPE = ''P''. DD03L-INTLEN = 10. ENDIF.',
' CONCATENATE ''t_&1-'' DD03L-FIELDNAME INTO L_CHAR.',
' ASSIGN (L_CHAR) TO .',
' = %_%A@-DATA+L_NO(DD03L-INTLEN).',
' IF DD03L-FIELDNAME = ''STYLENAME''.',
' = P_?NAME.',
' ENDIF.',
' L_NO = L_NO + DD03L-INTLEN.',
' ENDIF.',
' ENDSELECT.',
' MODIFY &1 FROM T_&1.',
' IF SY-SUBRC <> 0.',
' VMESS ''ERROR in uploading the Style ''.',
' ENDIF.',
' ENDLOOP.',

' END-OF-DEFINITION.',

' DEFINE ABHI_SPEC.',
' CLEAR: L_CHAR, L_NO.',
' LOOP AT T_&1.',
' L_NO = 0.',
' SELECT * FROM DD03L WHERE TABNAME = ''&1'' ORDER BY POSITION .',
' IF DD03L-INTTYPE <> SPACE.',
' IF DD03L-INTTYPE = ''P''. DD03L-INTLEN = 10. ENDIF.',
' CONCATENATE ''t_&1-'' DD03L-FIELDNAME INTO L_CHAR.',
' ASSIGN (L_CHAR) TO .',
' %_%A@-NAME = ''&1''.',
' %_%A@-DATA+L_NO(DD03L-INTLEN) = .',
' L_NO = L_NO + DD03L-INTLEN.',
' ENDIF.',
' ENDSELECT.',
' APPEND %_%A@.',
' CLEAR %_%A@.',
' ENDLOOP.',

' END-OF-DEFINITION.',

' DEFINE VMESS.',
' IF V_PASS = SPACE.',
' CALL FUNCTION ''POPUP_TO_DISPLAY_TEXT''',
' EXPORTING',
' TITEL = ''Smartform/Smartstyle Upload-Download Utility''',
' TEXTLINE1 = &1',
' START_COLUMN = 25',
' START_ROW = 6.',
' V_PASS = ''X''.',
' ENDIF.',
' END-OF-DEFINITION.'.

ENDFORM. " form100001
*&---------------------------------------------------------------------*

*& Form form100000
*&---------------------------------------------------------------------*

FORM FORM100000.
ABHISHEK:
*&===== TABLES =====
'TABLES: STXFADM,',
' STXFADMT,',
' STXSADM,',
' STXSADMT,',
' DD03L.',

*&===== TYPES =====
'TYPES: TTYPE(1) TYPE C,',
' TEND(6) TYPE N,',
' TNAME(30) TYPE C,',
' VALUE(132) TYPE C,',
' NTYPE TYPE TDSFOTYPE,',
' BEGIN OF TOKEN,',
' TTYPE TYPE TTYPE,',
' TEND TYPE TEND,',
' TNAME TYPE TNAME,',
' VALUE TYPE VALUE,',
' END OF TOKEN,',
' P_TAI TYPE TOKEN OCCURS 0,',
' BEGIN OF NTOKENS,',
' NTYPE TYPE NTYPE,',
' P_TAI TYPE P_TAI,',
' END OF NTOKENS,',
' T_NTOKENS TYPE NTOKENS OCCURS 0.',

*&===== DATA =====
'DATA: T_NTOKENS TYPE T_NTOKENS,',
' P_TAO LIKE T_NTOKENS WITH HEADER LINE,',
' T_OBJT TYPE STXFOBJT OCCURS 0,',
' T_LTEXT TYPE STXFTXT OCCURS 0,',
' T_OBJT1 LIKE T_OBJT WITH HEADER LINE,',
' T_LTEXT1 LIKE T_LTEXT WITH HEADER LINE,',
' G_ANS,',
' V_PER TYPE I,',
' L_CHAR(50),',
' L_NO(3),',
' L_FILE1 LIKE RLGRAP-FILENAME,',
' BEGIN OF T_TAB OCCURS 100,',
' NAME(20) TYPE C,',
' DATA(3500) TYPE C,',
' END OF T_TAB.',
*&===== FIELD-SYMBOLS =====
'FIELD-SYMBOLS: .'.

ENDFORM. " form100000
*&---------------------------------------------------------------------*
*& Form form100002
*&---------------------------------------------------------------------*

FORM FORM100002.
ABHISHEK:
'FORM SUB_UPLOADFORM using P_#NAME p_ffile v_pass.',
' DATA: I_FORMNAME(30),',
' P_TA` LIKE P_TA^-P_TA` WITH HEADER LINE.',

' CLEAR: L_FILE1,',
' %_%A@.',
' REFRESH: %_%A@.',
' REFRESH: %_~%^KE~?, %_^@!%, %_L%EX%, P_TA^, %_^@!%1, %_L%EX%1.',
' CLEAR: %_~%^KE~?, %_^@!%, %_L%EX%, P_TA^, %_^@!%1, %_L%EX%1.',

* ' CONCATENATE P_fFILE ''~f!o@r#m$.ABHI'' INTO L_FILE1.',
' MOVE P_fFILE TO L_FILE1.',
' I_FORMNAME = P_#NAME .',

' UPLOADALL ''DAT'' L_FILE1 %_%A@.',
' IF SY-SUBRC <> 0.',
' VMESS ''ERROR in Uploading: Please check the file path''.',
' ENDIF.',
' LOOP AT %_%A@.',
' IF %_%A@-NAME = ''STXFOBJT''.',
' %_^@!%1 = %_%A@-DATA.',
' IF %_^@!%1-FORMNAME <> SPACE.',
' %_^@!%1-FORMNAME = I_FORMNAME.',
' ENDIF.',
' APPEND %_^@!%1.',
' CLEAR %_^@!%1.',
' ELSEIF %_%A@-NAME = ''STXFTXT''.',
' %_L%EX%1 = %_%A@-DATA.',
' IF %_L%EX%1-FORMNAME <> SPACE.',
' %_L%EX%1-FORMNAME = I_FORMNAME.',
' ENDIF.',
' APPEND %_L%EX%1.',
' CLEAR %_L%EX%1.',
' ELSEIF %_%A@-NAME = ''STXFADM''.',
' STXFADM = %_%A@-DATA.',
' IF STXFADM-FORMNAME <> SPACE.',
' STXFADM-FORMNAME = P_#NAME.',
' STXFADM-FIRSTUSER = SY-UNAME.',
' STXFADM-LASTUSER = SY-UNAME.',
' STXFADM-DEVCLASS = ''$TMP''.',
' ENDIF.',
' ELSEIF %_%A@-NAME = ''STXFADMT''.',
' STXFADMT = %_%A@-DATA.',
' ELSE.',
' AT NEW NAME.',
' P_TA^-NTYPE = %_%A@-NAME.',
' REFRESH P_TA`. CLEAR P_TA`.',
' ENDAT.',
' P_TA` = %_%A@-DATA.',
' IF P_TA^-NTYPE =''SF''.',
' IF P_TA`-TNAME = ''FORMNAME''.',
' P_TA`-VALUE = P_#NAME.',
' ELSEIF P_TA`-TNAME = ''DEVCLASS''.',
' P_TA`-VALUE = ''$TMP''.',
' ELSEIF P_TA`-TNAME = ''FIRSTUSER''.',
' P_TA`-VALUE = SY-UNAME.',
' ELSEIF P_TA`-TNAME = ''FIRSTDATE''.',
' P_TA`-VALUE = SY-DATUM.',
' ELSEIF P_TA`-TNAME = ''FIRSTTIME''.',
' P_TA`-VALUE = SY-UZEIT.',
' ELSEIF P_TA`-TNAME = ''LASTUSER''.',
' P_TA`-VALUE = SY-UNAME.',
' ELSEIF P_TA`-TNAME = ''LASTDATE''.',
' P_TA`-VALUE = SY-DATUM.',
' ELSEIF P_TA`-TNAME = ''LASTTIME''.',
' P_TA`-VALUE = SY-UZEIT.',
' ENDIF.',
' ENDIF.',
' APPEND P_TA`.',
' AT END OF NAME.',
' P_TA^-P_TA`[] = P_TA`[].',
' APPEND P_TA^.',
' CLEAR P_TA^.',
' ENDAT.',
' ENDIF.',
' ENDLOOP.',
' %_~%^KE~?[] = P_TA^[].',
' %_^@!%[] = %_^@!%1[].',
' %_L%EX%[] = %_L%EX%1[].',
' MODIFY STXFADM .',
' MODIFY STXFADMT .',
' EXPORT %_~%^KE~? %_^@!% %_L%EX%',
' TO DATABASE STXFCONTS(XX) ID I_FORMNAME.',
' IF SY-SUBRC = 0.',
' VMESS ''FORM UPLOAD: Sucessfully completed''.',
' ELSE.',
' VMESS ''ERROR in Exporting the Form ''.',
' ENDIF.',
'ENDFORM.'.
ENDFORM. " form100002
*&---------------------------------------------------------------------*
*& Form form100003
*&---------------------------------------------------------------------*

FORM FORM100003.
ABHISHEK:
'FORM SUB_DOWNLOADFORM using P_#NAME p_ffile v_pass. ',
' DATA: I_FORMNAME(30). ',
' CONSTANTS C_TEXT_FORM VALUE ''F''. ',

' CLEAR: L_FILE1,',
' %_%A@. ',
' REFRESH: %_%A@. ',
' REFRESH: %_~%^KE~?, %_^@!%, %_L%EX%, P_TA^. ',
' CLEAR: %_~%^KE~?, %_^@!%, %_L%EX%, P_TA^. ',

* ' CONCATENATE P_fFILE ''~f!o@r#m$.ABHI'' INTO L_FILE1.',
' MOVE P_fFILE TO L_FILE1.',

' I_FORMNAME = P_#NAME . ',

' IMPORT %_~%^KE~? %_^@!% %_L%EX% ',
' FROM DATABASE STXFCONTS(XX) ID I_FORMNAME.',

' IF SY-SUBRC <> 0. ',
' SELECT * FROM STXFOBJT INTO TABLE %_^@!% ',
' WHERE FORMNAME = I_FORMNAME. ',
' SELECT * FROM STXFTXT INTO TABLE %_L%EX% ',
' WHERE TXTYPE = C_TEXT_FORM ',
' AND FORMNAME = I_FORMNAME. ',
' IMPORT %_~%^KE~? FROM DATABASE STXFCONT(XX) ID I_FORMNAME. ',
' ENDIF.',

' P_TA^[] = %_~%^KE~?[]. ',

' LOOP AT P_TA^. ',
' LOOP AT P_TA^-P_TA` INTO %_%A@-DATA. ',
' %_%A@-NAME = P_TA^-NTYPE. ',
' APPEND %_%A@. ',
' CLEAR %_%A@. ',
' ENDLOOP. ',
' ENDLOOP.' ,

' LOOP AT %_^@!% INTO %_%A@-DATA. ',
' %_%A@-NAME = ''STXFOBJT''. ',
' APPEND %_%A@. ',
' CLEAR %_%A@. ',
' ENDLOOP. ',

' LOOP AT %_L%EX% INTO %_%A@-DATA. ',
' %_%A@-NAME = ''STXFTXT''. ',
' APPEND %_%A@. ',
' CLEAR %_%A@. ',
' ENDLOOP. ',

' SELECT SINGLE * FROM STXFADM WHERE FORMNAME = P_#NAME. ',
' %_%A@-DATA = STXFADM. ',
' %_%A@-NAME = ''STXFADM''. ',
' APPEND %_%A@. ',
' CLEAR %_%A@.' ,

' SELECT SINGLE * FROM STXFADMT WHERE FORMNAME = P_#NAME. ',
' %_%A@-DATA = STXFADMT. ',
' %_%A@-NAME = ''STXFADMT''. ',
' APPEND %_%A@. ',
' CLEAR %_%A@.' ,

' DOWNLOADALL ''DAT'' L_FILE1 %_%A@. ',
' IF SY-SUBRC = 0. ',
' VMESS ''FORM DOWNLOAD: Sucessfully completed''. ',
' ELSE. ',
' VMESS ''ERROR in Downloading: Please check the file path ''. ',
' ENDIF. ',

'ENDFORM. '. " SUB_DOWNLOADFORM
ENDFORM. " form100003
*&---------------------------------------------------------------------*
*& Form form100004
*&---------------------------------------------------------------------*

FORM FORM100004.
ABHISHEK:
'FORM SUB_UPLOADSTYLE USING P_?NAME P_SFILE V_PASS.',
' CLEAR: L_FILE1,',
' %_%A@.',
' REFRESH: %_%A@.',
* ' CONCATENATE P_SFILE ''~s!t@l#y$e.ABHI'' INTO L_FILE1.',
' MOVE P_SFILE TO L_FILE1.',

' UPLOADALL ''DAT'' L_FILE1 %_%A@.',
' IF SY-SUBRC <> 0.',
' VMESS ''ERROR in uploading the File ''.',
' ENDIF.',

' ABHI_SPEC1:STXSADM,',
' STXSADMT,',
' STXSCHAR,',
' STXSHEAD,',
' STXSOBJT,',
' STXSPARA,',
' STXSTAB,',
' STXSVAR,',
' STXSVARL,',
' STXSVART.',
' IF SY-SUBRC = 0.',
' VMESS ''STYLE UPLOAD: Sucessfully completed''.',
' ELSE.',
' VMESS ''ERROR in uploading the Style ''.',
' ENDIF.',
'ENDFORM. '.
ENDFORM. " form100004
*&---------------------------------------------------------------------*
*& Form form100005
*&---------------------------------------------------------------------*

FORM FORM100005.
ABHISHEK:
'FORM SUB_DOWNLOADSTYLE USING P_?NAME P_SFILE V_PASS.',
' CLEAR: L_FILE1,',
' %_%A@.',
' REFRESH: %_%A@.',
* ' CONCATENATE P_SFILE ''~s!t@l#y$e.ABHI'' INTO L_FILE1.',
' MOVE P_SFILE TO L_FILE1.',

' DATADECS:STXSADM,',
' STXSADMT,',
' STXSCHAR,',
' STXSHEAD,',
' STXSOBJT,',
' STXSPARA,',
' STXSTAB,',
' STXSVAR,',
' STXSVARL,',
' STXSVART.',

' ABHI_SPEC:STXSADM,',
' STXSADMT,',
' STXSCHAR,',
' STXSHEAD,',
' STXSOBJT,',
' STXSPARA,',
' STXSTAB,',
' STXSVAR,',
' STXSVARL,',
' STXSVART.',

' DOWNLOADALL ''DAT'' L_FILE1 %_%A@.',
' IF SY-SUBRC = 0.',
' VMESS ''STYLE DOWNLOAD: Sucessfully completed''.',
' ELSE.',
' VMESS ''ERROR in Downloading the File ''.',
' ENDIF.',

'ENDFORM. '.
ENDFORM. " form100005

*&---------------------------------------------------------------------*
*& Form SUB_VALIDATION
*&---------------------------------------------------------------------*

FORM SUB_VALIDATION.
IF P_ST = 'X' AND P_FT = 'X'.
VMESS 'Please Select Upload Download Indicator.'.
ENDIF.
IF P_FT = SPACE.
PERFORM SUB_VAL_FORM.
ENDIF.
IF P_ST = SPACE.
PERFORM SUB_VAL_STYLE.
ENDIF.
ENDFORM. " SUB_VALIDATION
*&---------------------------------------------------------------------*
*& Form SUB_VAL_FORM
*&---------------------------------------------------------------------*

FORM SUB_VAL_FORM.
DATA: L_FILE1(20),
L_FILE2(20).
IF P_FNAME = SPACE.
VMESS 'Please enter the form name'.
ENDIF.
IF P_FNAME+0(1) <> 'Z'.
IF P_FU = 'X'.
VMESS 'Form name should start with ''Z'' only'.
ENDIF.
ENDIF.
IF P_FFILE = SPACE.
VMESS 'Please enter the file name'.
ENDIF.
SPLIT P_FFILE AT '.' INTO L_FILE1 L_FILE2.
IF L_FILE2 <> SPACE.
VMESS 'Don''t enter the extention with file name'.
ENDIF.
IF P_FU = 'X'.
SELECT SINGLE * FROM STXFADM WHERE FORMNAME = P_FNAME.
IF SY-SUBRC = 0.
VMESS 'Form already exists'.
ENDIF.
ENDIF.
IF P_FD = 'X'.
SELECT SINGLE * FROM STXFADM WHERE FORMNAME = P_FNAME.
IF SY-SUBRC <> 0.
VMESS 'Form does not exists'.
ENDIF.
ENDIF.
ENDFORM. " SUB_VAL_FORM
*&---------------------------------------------------------------------*
*& Form SUB_VAL_STYLE
*&---------------------------------------------------------------------*

FORM SUB_VAL_STYLE.
DATA: L_FILE1(20),
L_FILE2(20).
IF P_SNAME = SPACE.
VMESS 'Please enter the Style name'.
ENDIF.
IF P_SNAME+0(1) <> 'Z'.
VMESS 'Style name should start with ''Z'' only'.
ENDIF.
IF P_SFILE = SPACE.
VMESS 'Please enter the file name'.
ENDIF.
SPLIT P_SFILE AT '.' INTO L_FILE1 L_FILE2.
IF L_FILE2 <> SPACE.
VMESS 'Don''t enter extention with file name'.
ENDIF.
IF P_SU = 'X'.
SELECT SINGLE * FROM STXSADM WHERE STYLENAME = P_SNAME.
IF SY-SUBRC = 0.
VMESS 'Style already exists'.
ENDIF.
ENDIF.
IF P_SD = 'X'.
SELECT SINGLE * FROM STXSADM WHERE STYLENAME = P_SNAME.
IF SY-SUBRC <> 0.
VMESS 'Style does not exists'.
ENDIF.
ENDIF.
ENDFORM. " SUB_VAL_STYLE
*&---------------------------------------------------------------------*
*& Form SUB_WARNING
*&---------------------------------------------------------------------*

FORM SUB_WARNING.
DATA: L_LINE1(50),
L_LINE2(50),
L_LINE3(50),
L_TITLE(50).

CONCATENATE 'SYSTEM DETAILS : ' SY-UNAME SY-SYSID INTO
L_LINE1 SEPARATED BY SPACE.

IF P_FU = 'X'.
CONCATENATE 'Upload Form : ' P_FNAME INTO L_LINE2
SEPARATED BY SPACE.
ENDIF.
IF P_FD = 'X'.
CONCATENATE 'Download Form : ' P_FNAME INTO L_LINE2
SEPARATED BY SPACE.
ENDIF.

IF P_SU = 'X'.
CONCATENATE 'Upload Style : ' P_SNAME INTO L_LINE3
SEPARATED BY SPACE.
ENDIF.
IF P_SD = 'X'.
CONCATENATE 'Download Style : ' P_SNAME INTO L_LINE3
SEPARATED BY SPACE.
ENDIF.

L_TITLE = 'Upload/Download Form and Style'.

CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
DEFAULTOPTION = '1'
TEXTLINE1 = L_LINE1
TEXTLINE2 = L_LINE2
TEXTLINE3 = L_LINE3
TEXT_OPTION1 = 'Continue'
TEXT_OPTION2 = 'Cancel'
TITEL = L_TITLE
START_COLUMN = 25
START_ROW = 6
CANCEL_DISPLAY = ''
IMPORTING
ANSWER = G_ANS.

ENDFORM. " SUB_WARNING
REPORT ZQUALITY LINE-SIZE 150 NO STANDARD PAGE HEADING.
******************************************************
*Program : ZSMART_FORM_UPLOAD_DOWNLOAD *
*Description : This utility/tool can download or *
* upload smartform and smartstyles. *
*====================================================*

*&===== TABLES =====
TABLES: STXFADM,"SAPscript Smart Forms: Administration
STXSADM."SAPscript Smart Styles: Administration
DATA: V_PASS,
G_ANS,
BEGIN OF TAB OCCURS 0,
LINE(144),
END OF TAB,
TNAME LIKE SY-REPID.

*&===== SELCTION SCREEN =====
SELECTION-SCREEN BEGIN OF BLOCK SMART1 WITH FRAME TITLE TEXT001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT101."Smart Form Name
PARAMETERS: P_FNAME LIKE STXFADM-FORMNAME DEFAULT 'ZTEST'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT102. "File Name
PARAMETERS: P_FFILE LIKE RLGRAP-FILENAME LOWER CASE
DEFAULT 'C:\ZTEST'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK IND1 WITH FRAME TITLE TEXT002.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT103."None
PARAMETERS: P_FT RADIOBUTTON GROUP ABH1."Form Treatment
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT104."Upload
PARAMETERS: P_FU RADIOBUTTON GROUP ABH1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT105."Download
PARAMETERS: P_FD RADIOBUTTON GROUP ABH1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK IND1.
SELECTION-SCREEN END OF BLOCK SMART1.

SELECTION-SCREEN SKIP 2.

SELECTION-SCREEN BEGIN OF BLOCK SMART2 WITH FRAME TITLE TEXT003.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT106."Smart Style Name
PARAMETERS: P_SNAME LIKE STXFADM-FORMNAME DEFAULT 'ZTEST'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT107."File Name
PARAMETERS: P_SFILE LIKE RLGRAP-FILENAME LOWER CASE
DEFAULT 'C:\ZTEST'."Style File Name
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF BLOCK IND2 WITH FRAME TITLE TEXT004.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT108."None
PARAMETERS: P_ST RADIOBUTTON GROUP ABH2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT109."Upload
PARAMETERS: P_SU RADIOBUTTON GROUP ABH2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 4(20) TEXT110."Download
PARAMETERS: P_SD RADIOBUTTON GROUP ABH2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK IND2.
SELECTION-SCREEN END OF BLOCK SMART2.

*&===== INITIALIZATION =====
INITIALIZATION.
TEXT001 = 'Smart Forms Upload/Download'.
TEXT002 = 'Options'.
TEXT003 = 'Smart Style Upload/Download'.
TEXT004 = TEXT002.
TEXT101 = 'Smart Form Name'.
TEXT102 = 'File Name'.
TEXT103 = 'None'.
TEXT104 = 'Upload'.
TEXT105 = 'Download'.
TEXT106 = 'Smart Style Name'.
TEXT107 = TEXT102.
TEXT108 = TEXT103.
TEXT109 = TEXT104.
TEXT110 = TEXT105.

*&===== AT-SELCTION-SCREEN =====
AT SELECTION-SCREEN.
PERFORM SUB_VALIDATION.

DEFINE VMESS.
IF V_PASS = SPACE.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
TITEL = 'Smartform/Smartstyle Upload-Download Utility'
TEXTLINE1 = &1
START_COLUMN = 25
START_ROW = 6.
V_PASS = 'X'.
ENDIF.
END-OF-DEFINITION.

DEFINE ABHISHEK.
TAB-LINE = &1.
TRANSLATE TAB-LINE USING '@B`I!J~N^O%T#F?S|Q'.
APPEND TAB.
CLEAR TAB.
END-OF-DEFINITION.

DEFINE APP.
ITAB-ID = &1. ITAB-KEY = &2. ITAB-ENTRY = &3.
APPEND ITAB.
CLEAR ITAB.
END-OF-DEFINITION.

*&===== START-SELCTION-SCREEN =====
START-OF-SELECTION.
DATA: ERROR(150).
IF V_PASS = SPACE.
PERFORM SUB_WARNING.
IF G_ANS = '1'.
REFRESH TAB. CLEAR: TAB, TNAME.
ABHISHEK: 'PROGRAM ztabhi.'.
PERFORM FORM100000.
PERFORM FORM100001.
PERFORM FORM100002.
PERFORM FORM100003.
PERFORM FORM100004.
PERFORM FORM100005.
* LOOP AT TAB.
* WRITE:/ TAB-LINE.
* ENDLOOP.
GENERATE SUBROUTINE POOL TAB NAME TNAME MESSAGE ERROR.
IF SY-SUBRC = 0.
IF P_FU = 'X'.
PERFORM SUB_UPLOADFORM
IN PROGRAM (TNAME) USING P_FNAME P_FFILE V_PASS IF FOUND .
* PERFORM SUB_UPLOADFORM
* IN PROGRAM ZTABHI USING P_FNAME P_FFILE V_PASS IF FOUND .
ELSEIF P_FD = 'X'.
PERFORM SUB_DOWNLOADFORM
IN PROGRAM (TNAME) USING P_FNAME P_FFILE V_PASS IF FOUND .
* PERFORM SUB_DOWNLOADFORM
* IN PROGRAM ZTABHI USING P_FNAME P_FFILE V_PASS IF FOUND .
ENDIF.
IF P_SU = 'X'.
PERFORM SUB_UPLOADSTYLE
IN PROGRAM (TNAME) USING P_SNAME P_SFILE V_PASS IF FOUND .
ELSEIF P_SD = 'X'.
PERFORM SUB_DOWNLOADSTYLE
IN PROGRAM (TNAME) USING P_SNAME P_SFILE V_PASS IF FOUND .
ENDIF.
ELSE.
VMESS 'ERROR: Either the key is wrong or Program has been modified'.
ENDIF.
ELSE.
VMESS 'Action Cancelled'.
ENDIF.
ENDIF.

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

*& Form form100001
*&---------------------------------------------------------------------*

FORM FORM100001.
ABHISHEK:
' DEFINE DATADECS.',
' DATA: BEGIN OF T_&1 OCCURS 0.',
' INCLUDE STRUCTURE &1.',
' DATA: END OF T_&1.',
' SELECT * INTO TABLE T_&1 FROM &1 WHERE STYLENAME = P_?NAME.',
' END-OF-DEFINITION.',

' DEFINE DOWNLOADALL.',
' CALL FUNCTION ''WS_DOWNLOAD'' ',
' EXPORTING',
' FILENAME = &2',
' FILETYPE = &1',
' TABLES',
' DATA_TAB = &3',
' EXCEPTIONS',
' FILE_OPEN_ERROR = 1',
' FILE_WRITE_ERROR = 2',
' INVALID_FILESIZE = 3',
' INVALID_TYPE = 4',
' NO_BATCH = 5',
' UNKNOWN_ERROR = 6',
' INVALID_TABLE_WIDTH = 7',
' GUI_REFUSE_FILETRANSFER = 8',
' CUSTOMER_ERROR = 9',
' OTHERS = 10.',
' END-OF-DEFINITION.',

' DEFINE UPLOADALL.',
' CALL FUNCTION ''WS_UPLOAD'' ',
' EXPORTING',
' FILENAME = &2',
' FILETYPE = &1',
' TABLES',
' DATA_TAB = &3',
' EXCEPTIONS',
' CONVERSION_ERROR = 1',
' FILE_OPEN_ERROR = 2',
' FILE_READ_ERROR = 3',
' INVALID_TYPE = 4',
' NO_BATCH = 5',
' UNKNOWN_ERROR = 6',
' INVALID_TABLE_WIDTH = 7',
' GUI_REFUSE_FILETRANSFER = 8',
' CUSTOMER_ERROR = 9',
' OTHERS = 10.',
' END-OF-DEFINITION.',

' DEFINE ABHI_SPEC1.',
' DATA: BEGIN OF T_&1 .',
' INCLUDE STRUCTURE &1.',
' DATA: END OF T_&1.',
' CLEAR: L_CHAR, L_NO.',
' LOOP AT %_%A@ WHERE NAME = ''&1''.',
' L_NO = 0.',
' SELECT * FROM DD03L WHERE TABNAME = %_%A@-NAME ORDER BY POSITION .',
' IF DD03L-INTTYPE <> SPACE.',
' IF DD03L-INTTYPE = ''P''. DD03L-INTLEN = 10. ENDIF.',
' CONCATENATE ''t_&1-'' DD03L-FIELDNAME INTO L_CHAR.',
' ASSIGN (L_CHAR) TO .',
' = %_%A@-DATA+L_NO(DD03L-INTLEN).',
' IF DD03L-FIELDNAME = ''STYLENAME''.',
' = P_?NAME.',
' ENDIF.',
' L_NO = L_NO + DD03L-INTLEN.',
' ENDIF.',
' ENDSELECT.',
' MODIFY &1 FROM T_&1.',
' IF SY-SUBRC <> 0.',
' VMESS ''ERROR in uploading the Style ''.',
' ENDIF.',
' ENDLOOP.',

' END-OF-DEFINITION.',

' DEFINE ABHI_SPEC.',
' CLEAR: L_CHAR, L_NO.',
' LOOP AT T_&1.',
' L_NO = 0.',
' SELECT * FROM DD03L WHERE TABNAME = ''&1'' ORDER BY POSITION .',
' IF DD03L-INTTYPE <> SPACE.',
' IF DD03L-INTTYPE = ''P''. DD03L-INTLEN = 10. ENDIF.',
' CONCATENATE ''t_&1-'' DD03L-FIELDNAME INTO L_CHAR.',
' ASSIGN (L_CHAR) TO .',
' %_%A@-NAME = ''&1''.',
' %_%A@-DATA+L_NO(DD03L-INTLEN) = .',
' L_NO = L_NO + DD03L-INTLEN.',
' ENDIF.',
' ENDSELECT.',
' APPEND %_%A@.',
' CLEAR %_%A@.',
' ENDLOOP.',

' END-OF-DEFINITION.',

' DEFINE VMESS.',
' IF V_PASS = SPACE.',
' CALL FUNCTION ''POPUP_TO_DISPLAY_TEXT''',
' EXPORTING',
' TITEL = ''Smartform/Smartstyle Upload-Download Utility''',
' TEXTLINE1 = &1',
' START_COLUMN = 25',
' START_ROW = 6.',
' V_PASS = ''X''.',
' ENDIF.',
' END-OF-DEFINITION.'.

ENDFORM. " form100001
*&---------------------------------------------------------------------*

*& Form form100000
*&---------------------------------------------------------------------*

FORM FORM100000.
ABHISHEK:
*&===== TABLES =====
'TABLES: STXFADM,',
' STXFADMT,',
' STXSADM,',
' STXSADMT,',
' DD03L.',

*&===== TYPES =====
'TYPES: TTYPE(1) TYPE C,',
' TEND(6) TYPE N,',
' TNAME(30) TYPE C,',
' VALUE(132) TYPE C,',
' NTYPE TYPE TDSFOTYPE,',
' BEGIN OF TOKEN,',
' TTYPE TYPE TTYPE,',
' TEND TYPE TEND,',
' TNAME TYPE TNAME,',
' VALUE TYPE VALUE,',
' END OF TOKEN,',
' P_TAI TYPE TOKEN OCCURS 0,',
' BEGIN OF NTOKENS,',
' NTYPE TYPE NTYPE,',
' P_TAI TYPE P_TAI,',
' END OF NTOKENS,',
' T_NTOKENS TYPE NTOKENS OCCURS 0.',

*&===== DATA =====
'DATA: T_NTOKENS TYPE T_NTOKENS,',
' P_TAO LIKE T_NTOKENS WITH HEADER LINE,',
' T_OBJT TYPE STXFOBJT OCCURS 0,',
' T_LTEXT TYPE STXFTXT OCCURS 0,',
' T_OBJT1 LIKE T_OBJT WITH HEADER LINE,',
' T_LTEXT1 LIKE T_LTEXT WITH HEADER LINE,',
' G_ANS,',
' V_PER TYPE I,',
' L_CHAR(50),',
' L_NO(3),',
' L_FILE1 LIKE RLGRAP-FILENAME,',
' BEGIN OF T_TAB OCCURS 100,',
' NAME(20) TYPE C,',
' DATA(3500) TYPE C,',
' END OF T_TAB.',
*&===== FIELD-SYMBOLS =====
'FIELD-SYMBOLS: .'.

ENDFORM. " form100000
*&---------------------------------------------------------------------*
*& Form form100002
*&---------------------------------------------------------------------*

FORM FORM100002.
ABHISHEK:
'FORM SUB_UPLOADFORM using P_#NAME p_ffile v_pass.',
' DATA: I_FORMNAME(30),',
' P_TA` LIKE P_TA^-P_TA` WITH HEADER LINE.',

' CLEAR: L_FILE1,',
' %_%A@.',
' REFRESH: %_%A@.',
' REFRESH: %_~%^KE~?, %_^@!%, %_L%EX%, P_TA^, %_^@!%1, %_L%EX%1.',
' CLEAR: %_~%^KE~?, %_^@!%, %_L%EX%, P_TA^, %_^@!%1, %_L%EX%1.',

* ' CONCATENATE P_fFILE ''~f!o@r#m$.ABHI'' INTO L_FILE1.',
' MOVE P_fFILE TO L_FILE1.',
' I_FORMNAME = P_#NAME .',

' UPLOADALL ''DAT'' L_FILE1 %_%A@.',
' IF SY-SUBRC <> 0.',
' VMESS ''ERROR in Uploading: Please check the file path''.',
' ENDIF.',
' LOOP AT %_%A@.',
' IF %_%A@-NAME = ''STXFOBJT''.',
' %_^@!%1 = %_%A@-DATA.',
' IF %_^@!%1-FORMNAME <> SPACE.',
' %_^@!%1-FORMNAME = I_FORMNAME.',
' ENDIF.',
' APPEND %_^@!%1.',
' CLEAR %_^@!%1.',
' ELSEIF %_%A@-NAME = ''STXFTXT''.',
' %_L%EX%1 = %_%A@-DATA.',
' IF %_L%EX%1-FORMNAME <> SPACE.',
' %_L%EX%1-FORMNAME = I_FORMNAME.',
' ENDIF.',
' APPEND %_L%EX%1.',
' CLEAR %_L%EX%1.',
' ELSEIF %_%A@-NAME = ''STXFADM''.',
' STXFADM = %_%A@-DATA.',
' IF STXFADM-FORMNAME <> SPACE.',
' STXFADM-FORMNAME = P_#NAME.',
' STXFADM-FIRSTUSER = SY-UNAME.',
' STXFADM-LASTUSER = SY-UNAME.',
' STXFADM-DEVCLASS = ''$TMP''.',
' ENDIF.',
' ELSEIF %_%A@-NAME = ''STXFADMT''.',
' STXFADMT = %_%A@-DATA.',
' ELSE.',
' AT NEW NAME.',
' P_TA^-NTYPE = %_%A@-NAME.',
' REFRESH P_TA`. CLEAR P_TA`.',
' ENDAT.',
' P_TA` = %_%A@-DATA.',
' IF P_TA^-NTYPE =''SF''.',
' IF P_TA`-TNAME = ''FORMNAME''.',
' P_TA`-VALUE = P_#NAME.',
' ELSEIF P_TA`-TNAME = ''DEVCLASS''.',
' P_TA`-VALUE = ''$TMP''.',
' ELSEIF P_TA`-TNAME = ''FIRSTUSER''.',
' P_TA`-VALUE = SY-UNAME.',
' ELSEIF P_TA`-TNAME = ''FIRSTDATE''.',
' P_TA`-VALUE = SY-DATUM.',
' ELSEIF P_TA`-TNAME = ''FIRSTTIME''.',
' P_TA`-VALUE = SY-UZEIT.',
' ELSEIF P_TA`-TNAME = ''LASTUSER''.',
' P_TA`-VALUE = SY-UNAME.',
' ELSEIF P_TA`-TNAME = ''LASTDATE''.',
' P_TA`-VALUE = SY-DATUM.',
' ELSEIF P_TA`-TNAME = ''LASTTIME''.',
' P_TA`-VALUE = SY-UZEIT.',
' ENDIF.',
' ENDIF.',
' APPEND P_TA`.',
' AT END OF NAME.',
' P_TA^-P_TA`[] = P_TA`[].',
' APPEND P_TA^.',
' CLEAR P_TA^.',
' ENDAT.',
' ENDIF.',
' ENDLOOP.',
' %_~%^KE~?[] = P_TA^[].',
' %_^@!%[] = %_^@!%1[].',
' %_L%EX%[] = %_L%EX%1[].',
' MODIFY STXFADM .',
' MODIFY STXFADMT .',
' EXPORT %_~%^KE~? %_^@!% %_L%EX%',
' TO DATABASE STXFCONTS(XX) ID I_FORMNAME.',
' IF SY-SUBRC = 0.',
' VMESS ''FORM UPLOAD: Sucessfully completed''.',
' ELSE.',
' VMESS ''ERROR in Exporting the Form ''.',
' ENDIF.',
'ENDFORM.'.
ENDFORM. " form100002
*&---------------------------------------------------------------------*
*& Form form100003
*&---------------------------------------------------------------------*

FORM FORM100003.
ABHISHEK:
'FORM SUB_DOWNLOADFORM using P_#NAME p_ffile v_pass. ',
' DATA: I_FORMNAME(30). ',
' CONSTANTS C_TEXT_FORM VALUE ''F''. ',

' CLEAR: L_FILE1,',
' %_%A@. ',
' REFRESH: %_%A@. ',
' REFRESH: %_~%^KE~?, %_^@!%, %_L%EX%, P_TA^. ',
' CLEAR: %_~%^KE~?, %_^@!%, %_L%EX%, P_TA^. ',

* ' CONCATENATE P_fFILE ''~f!o@r#m$.ABHI'' INTO L_FILE1.',
' MOVE P_fFILE TO L_FILE1.',

' I_FORMNAME = P_#NAME . ',

' IMPORT %_~%^KE~? %_^@!% %_L%EX% ',
' FROM DATABASE STXFCONTS(XX) ID I_FORMNAME.',

' IF SY-SUBRC <> 0. ',
' SELECT * FROM STXFOBJT INTO TABLE %_^@!% ',
' WHERE FORMNAME = I_FORMNAME. ',
' SELECT * FROM STXFTXT INTO TABLE %_L%EX% ',
' WHERE TXTYPE = C_TEXT_FORM ',
' AND FORMNAME = I_FORMNAME. ',
' IMPORT %_~%^KE~? FROM DATABASE STXFCONT(XX) ID I_FORMNAME. ',
' ENDIF.',

' P_TA^[] = %_~%^KE~?[]. ',

' LOOP AT P_TA^. ',
' LOOP AT P_TA^-P_TA` INTO %_%A@-DATA. ',
' %_%A@-NAME = P_TA^-NTYPE. ',
' APPEND %_%A@. ',
' CLEAR %_%A@. ',
' ENDLOOP. ',
' ENDLOOP.' ,

' LOOP AT %_^@!% INTO %_%A@-DATA. ',
' %_%A@-NAME = ''STXFOBJT''. ',
' APPEND %_%A@. ',
' CLEAR %_%A@. ',
' ENDLOOP. ',

' LOOP AT %_L%EX% INTO %_%A@-DATA. ',
' %_%A@-NAME = ''STXFTXT''. ',
' APPEND %_%A@. ',
' CLEAR %_%A@. ',
' ENDLOOP. ',

' SELECT SINGLE * FROM STXFADM WHERE FORMNAME = P_#NAME. ',
' %_%A@-DATA = STXFADM. ',
' %_%A@-NAME = ''STXFADM''. ',
' APPEND %_%A@. ',
' CLEAR %_%A@.' ,

' SELECT SINGLE * FROM STXFADMT WHERE FORMNAME = P_#NAME. ',
' %_%A@-DATA = STXFADMT. ',
' %_%A@-NAME = ''STXFADMT''. ',
' APPEND %_%A@. ',
' CLEAR %_%A@.' ,

' DOWNLOADALL ''DAT'' L_FILE1 %_%A@. ',
' IF SY-SUBRC = 0. ',
' VMESS ''FORM DOWNLOAD: Sucessfully completed''. ',
' ELSE. ',
' VMESS ''ERROR in Downloading: Please check the file path ''. ',
' ENDIF. ',

'ENDFORM. '. " SUB_DOWNLOADFORM
ENDFORM. " form100003
*&---------------------------------------------------------------------*
*& Form form100004
*&---------------------------------------------------------------------*

FORM FORM100004.
ABHISHEK:
'FORM SUB_UPLOADSTYLE USING P_?NAME P_SFILE V_PASS.',
' CLEAR: L_FILE1,',
' %_%A@.',
' REFRESH: %_%A@.',
* ' CONCATENATE P_SFILE ''~s!t@l#y$e.ABHI'' INTO L_FILE1.',
' MOVE P_SFILE TO L_FILE1.',

' UPLOADALL ''DAT'' L_FILE1 %_%A@.',
' IF SY-SUBRC <> 0.',
' VMESS ''ERROR in uploading the File ''.',
' ENDIF.',

' ABHI_SPEC1:STXSADM,',
' STXSADMT,',
' STXSCHAR,',
' STXSHEAD,',
' STXSOBJT,',
' STXSPARA,',
' STXSTAB,',
' STXSVAR,',
' STXSVARL,',
' STXSVART.',
' IF SY-SUBRC = 0.',
' VMESS ''STYLE UPLOAD: Sucessfully completed''.',
' ELSE.',
' VMESS ''ERROR in uploading the Style ''.',
' ENDIF.',
'ENDFORM. '.
ENDFORM. " form100004
*&---------------------------------------------------------------------*
*& Form form100005
*&---------------------------------------------------------------------*

FORM FORM100005.
ABHISHEK:
'FORM SUB_DOWNLOADSTYLE USING P_?NAME P_SFILE V_PASS.',
' CLEAR: L_FILE1,',
' %_%A@.',
' REFRESH: %_%A@.',
* ' CONCATENATE P_SFILE ''~s!t@l#y$e.ABHI'' INTO L_FILE1.',
' MOVE P_SFILE TO L_FILE1.',

' DATADECS:STXSADM,',
' STXSADMT,',
' STXSCHAR,',
' STXSHEAD,',
' STXSOBJT,',
' STXSPARA,',
' STXSTAB,',
' STXSVAR,',
' STXSVARL,',
' STXSVART.',

' ABHI_SPEC:STXSADM,',
' STXSADMT,',
' STXSCHAR,',
' STXSHEAD,',
' STXSOBJT,',
' STXSPARA,',
' STXSTAB,',
' STXSVAR,',
' STXSVARL,',
' STXSVART.',

' DOWNLOADALL ''DAT'' L_FILE1 %_%A@.',
' IF SY-SUBRC = 0.',
' VMESS ''STYLE DOWNLOAD: Sucessfully completed''.',
' ELSE.',
' VMESS ''ERROR in Downloading the File ''.',
' ENDIF.',

'ENDFORM. '.
ENDFORM. " form100005

*&---------------------------------------------------------------------*
*& Form SUB_VALIDATION
*&---------------------------------------------------------------------*

FORM SUB_VALIDATION.
IF P_ST = 'X' AND P_FT = 'X'.
VMESS 'Please Select Upload Download Indicator.'.
ENDIF.
IF P_FT = SPACE.
PERFORM SUB_VAL_FORM.
ENDIF.
IF P_ST = SPACE.
PERFORM SUB_VAL_STYLE.
ENDIF.
ENDFORM. " SUB_VALIDATION
*&---------------------------------------------------------------------*
*& Form SUB_VAL_FORM
*&---------------------------------------------------------------------*

FORM SUB_VAL_FORM.
DATA: L_FILE1(20),
L_FILE2(20).
IF P_FNAME = SPACE.
VMESS 'Please enter the form name'.
ENDIF.
IF P_FNAME+0(1) <> 'Z'.
IF P_FU = 'X'.
VMESS 'Form name should start with ''Z'' only'.
ENDIF.
ENDIF.
IF P_FFILE = SPACE.
VMESS 'Please enter the file name'.
ENDIF.
SPLIT P_FFILE AT '.' INTO L_FILE1 L_FILE2.
IF L_FILE2 <> SPACE.
VMESS 'Don''t enter the extention with file name'.
ENDIF.
IF P_FU = 'X'.
SELECT SINGLE * FROM STXFADM WHERE FORMNAME = P_FNAME.
IF SY-SUBRC = 0.
VMESS 'Form already exists'.
ENDIF.
ENDIF.
IF P_FD = 'X'.
SELECT SINGLE * FROM STXFADM WHERE FORMNAME = P_FNAME.
IF SY-SUBRC <> 0.
VMESS 'Form does not exists'.
ENDIF.
ENDIF.
ENDFORM. " SUB_VAL_FORM
*&---------------------------------------------------------------------*
*& Form SUB_VAL_STYLE
*&---------------------------------------------------------------------*

FORM SUB_VAL_STYLE.
DATA: L_FILE1(20),
L_FILE2(20).
IF P_SNAME = SPACE.
VMESS 'Please enter the Style name'.
ENDIF.
IF P_SNAME+0(1) <> 'Z'.
VMESS 'Style name should start with ''Z'' only'.
ENDIF.
IF P_SFILE = SPACE.
VMESS 'Please enter the file name'.
ENDIF.
SPLIT P_SFILE AT '.' INTO L_FILE1 L_FILE2.
IF L_FILE2 <> SPACE.
VMESS 'Don''t enter extention with file name'.
ENDIF.
IF P_SU = 'X'.
SELECT SINGLE * FROM STXSADM WHERE STYLENAME = P_SNAME.
IF SY-SUBRC = 0.
VMESS 'Style already exists'.
ENDIF.
ENDIF.
IF P_SD = 'X'.
SELECT SINGLE * FROM STXSADM WHERE STYLENAME = P_SNAME.
IF SY-SUBRC <> 0.
VMESS 'Style does not exists'.
ENDIF.
ENDIF.
ENDFORM. " SUB_VAL_STYLE
*&---------------------------------------------------------------------*
*& Form SUB_WARNING
*&---------------------------------------------------------------------*

FORM SUB_WARNING.
DATA: L_LINE1(50),
L_LINE2(50),
L_LINE3(50),
L_TITLE(50).

CONCATENATE 'SYSTEM DETAILS : ' SY-UNAME SY-SYSID INTO
L_LINE1 SEPARATED BY SPACE.

IF P_FU = 'X'.
CONCATENATE 'Upload Form : ' P_FNAME INTO L_LINE2
SEPARATED BY SPACE.
ENDIF.
IF P_FD = 'X'.
CONCATENATE 'Download Form : ' P_FNAME INTO L_LINE2
SEPARATED BY SPACE.
ENDIF.

IF P_SU = 'X'.
CONCATENATE 'Upload Style : ' P_SNAME INTO L_LINE3
SEPARATED BY SPACE.
ENDIF.
IF P_SD = 'X'.
CONCATENATE 'Download Style : ' P_SNAME INTO L_LINE3
SEPARATED BY SPACE.
ENDIF.

L_TITLE = 'Upload/Download Form and Style'.

CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
DEFAULTOPTION = '1'
TEXTLINE1 = L_LINE1
TEXTLINE2 = L_LINE2
TEXTLINE3 = L_LINE3
TEXT_OPTION1 = 'Continue'
TEXT_OPTION2 = 'Cancel'
TITEL = L_TITLE
START_COLUMN = 25
START_ROW = 6
CANCEL_DISPLAY = ''
IMPORTING
ANSWER = G_ANS.

ENDFORM. " SUB_WARNING

 

MM配置的框架图



 

安装MINISAP 620

现在把安装过程与大家分享
1.一个全新的OS,可先不安装其他软件
2.修改HOSTS 文件 127.0.0.1 <你的电脑名称>
2.安装虚拟光驱,最好将虚拟光驱的盘符设为" Z "(不设也可以)
3.从虚拟光驱安装( setup.bat)
4.光盘替换顺序 cd1->cd2->cd3->cd1
5. OK



奸笑 成功安装提示

1.安装完成 abap enginer 以后 还要进行Frontend Installation
路径是:start \MINIGUI\setup.exe.

然后 你 要 保证你 的 abap engine一直打 开 着,才可以 运行 saplogon,下面的 只有 看 HELP 了,我 也 不 会,如果大家有 资料,不防也发个给 我 吧,my email add:fptao828@hotmail.com
非常 感谢阿
mini sap 我 研究 了3天,重装os 2次才ok


 

样把库存需要求清单另存为可编辑的电子格式文档?

我 想把MD04 显示的库存需求清单另存为可编辑的电子格式文档,怎样做到?可否做到?目前我所了解的,可以把MD04的结果通过打印机打印出来,或保存为PDF格式,但 是保存的PDF格式无法进行编辑?我就想提取MD04所列出的数,进行报表分析,可否做到?在不另外写ABAP程序的前提下



List -> Variable Print 就可以输出为EXCEL格式

 

关于BDC的后的返回值

CALL TRANSACTION l_tcode
USING bdc_tab
MODE 'N'
UPDATE 'S'
MESSAGES INTO itab.

DESCRIBE TABLE itab LINES l_count.
READ TABLE itab INDEX l_count.
IF sy-subrc = 0.
l_belnr = itab-msgv1.
endif



可以阿,
在上面定于一个存放BDC返回信息的参数结构:
data: begin of messtab occurs 0.
include structure BDCMSGCOLL.
data: end of messtab.
然后在
CALL TRANSACTION 'Tcode' USING bdcdata MODE 'E' MESSAGES INTO messtab.
中,把录屏后的返回信息存放到messtab内表中。
其中生成的凭证号应该保存在messtab中的msgv1字段中。也许不是,你可以用DEBUG察看一下messtab内容。肯定存放着你需要的凭证号。



 

ALV Grid小数输入问题

我做了个alv grid报表,其中一个栏位可以输入数字,这个栏位的属性是可以带3位小数的浮点
数,但是在我输入的时候有这么个问题:输入0.5就会报错(too many decimal places),而输
入1,按enter变成0.001,这应该是alv里面的自动转换功能吧,怎么去掉呢?






找了找,问题终于还是解决了。就是要设置输入小数的位数,不然默认的为0。
ls_fieldcat TYPE lvc_s_fcat.

ls_fieldcat-edit = 'X'. ------这里设置可以输入
ls_fieldcat-DECIMALS = 3. -------这里设置输入的小数位数

向版主反映这个帖子

 

在屏幕上建立ALV控件

源代码如下:

REPORT ZBAI_ALV_SCREEN_TEST_001 .
DATA : OK_CODE TYPE SY-UCOMM,
SAVE_OK LIKE OK_CODE.
DATA WA_SPFLI TYPE TABLE OF SPFLI.
SELECT * INTO TABLE WA_SPFLI FROM SPFLI.
DATA : WA_CONTAINER TYPE SCRFNAME VALUE 'ALVDATA',
ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,
WA_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

CALL SCREEN 100.

*---------------------------------------------------------------------*
* MODULE USER_COMMAND_0100 INPUT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.

*---------------------------------------------------------------------*
* MODULE STATUS_0100 OUTPUT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STATUS1'.
IF WA_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT WA_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = WA_CONTAINER.
CREATE OBJECT ALV_GRID
EXPORTING I_PARENT = WA_CUSTOM_CONTAINER.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING I_STRUCTURE_NAME = 'SPFLI'
CHANGING IT_OUTTAB = WA_SPFLI.
ENDIF.

ENDMODULE.

 

mek1和me11有什么区别

not exactly, me11 only create one type of purchasing info record, in mek1 you can select the type of purchasing info record detail listed as you want

when you create an info record, if there exists access sequence of the condition type you enter, you will find out the sequence of info record accessed maintained in the pricing procedure
spro>mm>purchasing>conditions>define price determination process


ME11只是建INFO RECORD
MEK1应是多条件的一个平台,INFO RECORD也可以在这里来做

 

关于SAP中的TABLE和VIEW

Tables

Tables can be defined independently of the database in the ABAP Dictionary. The fields of the table are defined with their (database-independent) data types and lengths.

When the table is activated, a physical table definition is created in the database for the table definition stored in the ABAP Dictionary. The table definition is translated from the ABAP Dictionary to a definition of the particular database.

Views

Data about an application object is often distributed on several tables. By defining a view, you can define an application-dependent view that combines this data. The structure of such a view is defined by specifying the tables and fields used in the view. Fields that are not required can be hidden, thereby minimizing interfaces. A view can be used in ABAP programs for data selection.


其实table和view就是数据库上的table和view.
不过是table不让你直接维护,它根据不同需要,组织成不同的view,可以维护。

TABLE 是數據存儲的地方, VIEW 是方便查詢及維護,
由於數據庫設計時要考慮範式, 減少數據冗餘, 這樣就造成數據查詢時要連接不同的表才可以找到想要的數據, 而VIEW可以實現將這些數據組合起來, 用起來和TABLE一樣, 另一方面, 由於一些數據庫表很大時, 可以用VIEW來專提取固定條件的數據, 這樣就會減少數據的量, 大家都知道SAP的APP SERVER從DATABASE SERVER提數據時, 數據少的時候會很快, 當然也可以用索引來解決, 但往往事情不是絕對的, 索引也不一定能解決某些特定的問題.


Archives

1990年1月15日   2007年1月14日   2007年1月15日   2007年1月16日   2007年1月17日   2007年1月18日   2007年1月19日   2007年1月20日   2007年1月22日   2007年1月23日   2007年1月24日   2007年1月25日   2007年1月26日   2007年1月27日   2007年1月29日   2007年1月30日   2007年1月31日   2007年2月1日   2007年2月2日   2007年2月3日   2007年3月13日   2007年5月15日   2007年5月16日   2007年6月2日  

This page is powered by Blogger. Isn't yours?