|
2 examples on using a dataset.
Example 1 *&---------------------------------------------------------------------* *& Form SENDTO_UNIX *&---------------------------------------------------------------------* FORM SENDTO_UNIX. * open data set to transfer extract data OPEN DATASET Z_FILE_NAME FOR OUTPUT IN TEXT MODE. IF SY-SUBRC NE 0. * File could not be opened for writing WRITE: / TEXT-006. LI_WRITE_ERROR = 1. EXIT. ENDIF. LOOP AT IT_PAYR. TRANSFER IT_PAYR TO Z_FILE_NAME. ENDLOOP. * close dataset CLOSE DATASET Z_FILE_NAME. ENDFORM. " SENDTO_UNIX *&---------------------------------------------------------------------* Example 2 OPEN DATASET OUTFILE FOR OUTPUT IN TEXT MODE. * if the timestamped file cannot be created, do not process the * input file, because the input file is deleted after processing, * and there would be no record of the data. if not sy-subrc is initial. *'ERROR opening file & for output' close dataset infile. message i033 with outfile. continue. "process next vendor's file endif. do. read dataset infile into izss7b20. case sy-subrc. when 0. transfer izss7b20 to outfile. if izss7b20-datacode = 'T'. "trailer rec perform process_one_vendor using infile. exit. "process next vendor's file endif. check izss7b20-datacode = 'D'. "data rec move-corresponding uty_vendors to ie020. move-corresponding izss7b20 to ie020. when 4. "EOF perform process_one_vendor using infile. exit. "process next vendor's file when others. *ERROR reading dataset & on & message w015 with infile sy-datum. exit. "discontinue file reads endcase. enddo. close dataset: infile, outfile. delete dataset infile.
Related Items:
|