The decision and creation of SAP folders

Source: Internet
Author: User

"Transfer from http://blog.csdn.net/saphome/article/details/6956918"

The determination and creation of SAP folder existence

2010-08-29 20:15

Correlation function: Ws_query: Determines whether the folder path exists. Gui_create_directory: Create folder.

Checks whether the specified folder exists and creates a new folder if it does not exist.

Report z_example_01.

Parameter:l_file type LocalFile.
Data:status Type C.

The path to the Save folder
Data:begin of folder occurs 0,
Dire type LocalFile,
End of folder.

"Saves the folder path recognition symbol.
Data:begin of sign occurs 0,
SIG Type C,
End of sign.

Start-of-selection.
Clear:folder[],sign[],status.
"New folder path recognition symbol, if no relevant symbol is invalid path
Sign-sig = '/'.
Append sign.
Sign-sig = ' \ '.
Append sign.
Search L_file for sign.
"Determines if the folder path string is valid, invalid exit
If SY-SUBRC <> 0.
Message e005 (zmess) with ' not valuable directory! '.
Exit.
Else.
"Check if the folder already exists
Perform checkdir using l_file changing status.
If status = 1.
Message e005 (zmess) with ' The Directory is exit! '.
Exit.
endif.
endif.

Split l_file at sign into table folder.
Read Table folder index 1.
L_file = Folder-dire. " The first behavior letter of the inner table
Loop at folder.
"Iterates through the folder characters, checks if the path exists, and does not create the
If Sy-tabix > 1.
Concatenate l_file ' \ ' Folder-dire into L_file.
Perform checkdir using l_file changing status.

If status = 0.
Perform createrdir using L_file.

endif.
endif.
Endloop.
*---------------------------------------------------------
*-Check if the path exists, the function returns 1, there is no return 0--------
*---------------------------------------------------------
Form checkdir using dir type localfile changing ret type C.
Call FUNCTION ' Ws_query '
Exporting
* Environment =
FILENAME = DIR
QUERY = ' DE '
* WINID =
Importing
RETURN = RET
EXCEPTIONS
Inv_query = 1
No_batch = 2
Frontend_error = 3
OTHERS = 4.
EndForm. "Checkdir
*---------------------------------------------------------
*-----Create folders based on path----------------------------------
*---------------------------------------------------------
FORM createrdir USING DIR TYPE localfile.
Call FUNCTION ' Gui_create_directory '
Exporting
DIRNAME = DIR
EXCEPTIONS
FAILED = 1
OTHERS = 2.
WRITE:/' CREATE DIRECTOR success,path: ', DIR.
EndForm. "Createrdir

The decision and creation of SAP folders

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.