Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Home arrow Sample Code arrow ABAP Reports arrow Using a Dataset
Using a Dataset PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Anon.   
Tuesday, 13 February 2007

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:

 
< Prev   Next >

Google Search

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor