Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

[b]Urgent: [/b] Error: Pipe 'Compress' was closed

Former Member
0 Kudos
128

I am trying to extract data from SAP and put in Unix flat file. The amt of data selected will be huge and the unix file will have to be compressed. To do this, I am using Filter 'compress' when I open dataset for output. As part of the I am transferring in the select/end select statement. So each record is read from SAP and transfered to the flat file. After a 1000 records, it exits out of the select /end selcect to commit work. After commiting, goes back to finish selection.

The code is breaking at commit work.

<b>The error says: Pipes can only be open using Open dataset ... filter .. within a 'Unit of Work'.

A 'Rollout' closes the pipe automatically

My question is, do I need to commit work since I am selecting and transferring each record one at a time? If yes, how do I compress and commit after 1000 records with getting this error..</b>

FORM F_WRITE_AUFK. ' <- Form

CLEAR: GV_ERROR, GV_RECCNT, GV_T_AMT, GV_T_QTY,

GV_T_DOCS, GV_PREVIOUS_REC_ID, GV_PASSCNT.

----


Open in compress mode -

Data: GC_COMMIT dafault '1000'.

OPEN DATASET LV_FILE FOR OUTPUT in text mode encoding default filter 'compress'.

IF GV_ERROR = 'X'.

EXIT.

ENDIF.

IF GV_ERROR = 'X'.

EXIT.

ELSE.

DO. " Loop to commit work

*-------

SELECT AUFNR AUART AUTYP ERNAM AENAM AEDAT KTEXT

FROM AUFK INTO gs_AUFK

WHERE AUFNR IN S_AUFNR

AND AUFNR > GV_PREVIOUS_REC_ID

ORDER BY AUFNR. " Select into a work area

GV_PREVIOUS_REC_ID = GS_AUFK-AUFNR.

ADD 1 TO GV_PASSCNT.

PERFORM F_TRANSFER_DATASET USING P_F_AUFK GS_AUFK CHANGING GV_ERROR.

IF GV_PASSCNT = GC_COMMIT. " Exit when ready to commit work.

EXIT.

ENDIF.

ENDSELECT.

*-------

IF GV_PASSCNT = GC_COMMIT.

COMMIT WORK.

CLEAR GV_PASSCNT.

*------Commit work and go back to the select/endselect to get more records

ELSE.

EXIT.

ENDIF.

ENDDO.

ENDIF.

IF GV_ERROR = 'X'.

EXIT.

ELSE.

PERFORM F_CLOSEDATASET USING P_F_AUFK CHANGING GV_ERROR.

ENDIF.

ENDFORM.<b></b>

1 ACCEPTED SOLUTION

Former Member
0 Kudos
83

COMMIT is an SQL command and I don't think it will have any effect on you dataset. I think this should work:



FORM f_write_aufk.

  CLEAR: gv_error, gv_reccnt, gv_t_amt, gv_t_qty,
  gv_t_docs, gv_previous_rec_id, gv_passcnt.

*--------Open in compress mode ----------------------------------------*
  DATA: gc_commit dafault '1000'.
  OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT FILTER
          'compress'.
  IF sy-subrc = 0.

*-------
    SELECT aufnr auart autyp ernam aenam aedat ktext
    FROM aufk INTO gs_aufk
    WHERE aufnr IN s_aufnr.

      PERFORM f_transfer_dataset
        USING p_f_aufk gs_aufk CHANGING gv_error.

    ENDSELECT.
*-------

    PERFORM f_closedataset USING p_f_aufk CHANGING gv_error.

  ENDIF.

ENDFORM.                    "F_WRITE_AUFK

Rob

9 REPLIES 9

Former Member
0 Kudos
84

COMMIT is an SQL command and I don't think it will have any effect on you dataset. I think this should work:



FORM f_write_aufk.

  CLEAR: gv_error, gv_reccnt, gv_t_amt, gv_t_qty,
  gv_t_docs, gv_previous_rec_id, gv_passcnt.

*--------Open in compress mode ----------------------------------------*
  DATA: gc_commit dafault '1000'.
  OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT FILTER
          'compress'.
  IF sy-subrc = 0.

*-------
    SELECT aufnr auart autyp ernam aenam aedat ktext
    FROM aufk INTO gs_aufk
    WHERE aufnr IN s_aufnr.

      PERFORM f_transfer_dataset
        USING p_f_aufk gs_aufk CHANGING gv_error.

    ENDSELECT.
*-------

    PERFORM f_closedataset USING p_f_aufk CHANGING gv_error.

  ENDIF.

ENDFORM.                    "F_WRITE_AUFK

Rob

Former Member
0 Kudos
83

My question with commit work is than. I am doing select/endselect instead of downloading in internal and to the file as one package ... so that the computer won't run out of memory. The internal table will be huge. The reason I added commit work is to make sure that all records in the workarea are transferred to the flat file and not stored into cache. Basically, you are saying that I don't need to commit work to a flat file. I would only use it if I was updating something in SAP...

Do I understand it correctly?

0 Kudos
83

That's what I was saying, but now I'm really not sure what effect the commit will have on temporary tables set up by the SAP kernel. Anyway, I would say try to get rid of the commit and see if it works without it.

Rob

Former Member
0 Kudos
83

It does work w/o commit work. It compresses fine if there is no commit work involved. But I included commit work just to make sure that records are transfered to file atleast once every 1000 records.

I need to know for sure that the records are not stored in cache. If they are, the prog will crash if it runs out of memory.

Basically, when we say, transfer record, does it transfer or does it store in cache until the program ends? Also, does commit work have any effect on flat files at all? or does it only have effect if something needs to be commited to SAP?

I can't remove commit without knowing that.

0 Kudos
83

The records are transferred one at a time. If you exit from everything after doing a single WRITE, you should find that record on the server.

Rob

0 Kudos
83

At this stage, I would say to try it. If it doesn't work with the large dataset, then revisit it at that time how to handle this.

Rob

Former Member
0 Kudos
83

Are we sure that Exit doesn't trigger an implicit commit? So if I exited at 1001 record, all records are transfered only as soon as exit is triggered.. not before that.

Former Member
0 Kudos
83

I know.. it's a little hard to say. I can't really wait for the code to break in the future. I have to explain to the tech designer before i can take it out and he seems to think there is a way to make both of them work. There is another code written in 97 that is doing both commit and compress but I'm not able to do it. Maybe SAP has changed in the past 8 years to exit if both are used together. But I'll keep looking. I really appreciate your help. Thank you so much. I have assigned points for all your replies.

0 Kudos
83

Well, I believe in simplicity. You can try to guard against all possible problems, but I try to take care of things I know can hurt me. If there are potential problems that I can think of and can solve, then I take care of them as well. But potential problems that are difficult to solve and not critical, I think, are best left.

Rob