Application Development and Automation 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: 
Read only

write to PCL2

Former Member
0 Likes
1,286

Hello.

I have to write data from an internal table to cluster table PCL2.

Currently I write the data like this:

INSERT pcl2 from i_pcl2.

Now the problem, when I check internal table I_PCL2 in debug it contains the correct data. But in the database the UNAME, CLUSTERID, SRTFD,... changes..

SRTFD should be 00000038 but instead it gets changed to 0000003800000001.

Is it possible that I have to use a function or something to write data to PCL2?

Greets

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,151

Bert,

When I write to a clustered table, I use EXPORT.

Like this


* Defined in _TOP
DATA:
  BEGIN OF text_idx,
    appl     LIKE zlmetext-appl,
    letterid LIKE zlmetext-letterid,
    srtf2    LIKE zlmetext-srtf2,
  END OF text_idx.


* In my FORM to update/insert
  CHECK data_has_changed = 'X'.

  CHECK NOT it_ltr_text IS INITIAL.

  text_idx-appl     = zlmetext-appl.
  text_idx-letterid = zlmetext-letterid.
  CLEAR: text_idx-srtf2.

  CASE base_relid.
    WHEN c_lm_relid.
      EXPORT letterdesc  FROM zlmetext-letterdesc
             letteravail FROM zlmetext-letteravail
             subject     FROM zlmetext-subject
             erdat       FROM zlmetext-erdat
             ernam       FROM zlmetext-ernam
             aedat       FROM zlmetext-aedat
             aenam       FROM zlmetext-aenam
             letter      FROM it_ltr_text     " This is my IT to be stored in the Clustered area
        TO DATABASE zlmetext(lm) ID text_idx.
    WHEN OTHERS.
  ENDCASE.

8 REPLIES 8
Read only

Former Member
0 Likes
1,152

Bert,

When I write to a clustered table, I use EXPORT.

Like this


* Defined in _TOP
DATA:
  BEGIN OF text_idx,
    appl     LIKE zlmetext-appl,
    letterid LIKE zlmetext-letterid,
    srtf2    LIKE zlmetext-srtf2,
  END OF text_idx.


* In my FORM to update/insert
  CHECK data_has_changed = 'X'.

  CHECK NOT it_ltr_text IS INITIAL.

  text_idx-appl     = zlmetext-appl.
  text_idx-letterid = zlmetext-letterid.
  CLEAR: text_idx-srtf2.

  CASE base_relid.
    WHEN c_lm_relid.
      EXPORT letterdesc  FROM zlmetext-letterdesc
             letteravail FROM zlmetext-letteravail
             subject     FROM zlmetext-subject
             erdat       FROM zlmetext-erdat
             ernam       FROM zlmetext-ernam
             aedat       FROM zlmetext-aedat
             aenam       FROM zlmetext-aenam
             letter      FROM it_ltr_text     " This is my IT to be stored in the Clustered area
        TO DATABASE zlmetext(lm) ID text_idx.
    WHEN OTHERS.
  ENDCASE.

Read only

0 Likes
1,151

Sry but I totally do not understand what that code does..

How could I fit that in my solution with PCL2?

Thanx for the reply

Read only

0 Likes
1,151

This is my clustered table defenition


ZLMETEXT	MANDT
	RELID
	APPL
	LETTERID
	SRTF2
	LETTERDESC
	LETTERAVAIL
	SUBJECT
	ERDAT
	ERNAM
	AEDAT
	AENAM
	CLUSTR
ZLMETEXT	CLUSTD

In the EXPORT mentioned, it poplulates/updates these fields based on the parameters in the EXPORT.

RELID is part of the key and in my case indicates this is the Letter Storage part of the clustered table (because you can store multiple formats in Clustered Tables)

APPL is the application the Form Letters are for

LETTERID is the key to that letter

SRTF2 is a required part of the key

up to the CLUSTR Field the rest of the fields are simply stored.


     EXPORT letterdesc  FROM zlmetext-letterdesc
             letteravail FROM zlmetext-letteravail
             subject     FROM zlmetext-subject
             erdat       FROM zlmetext-erdat
             ernam       FROM zlmetext-ernam
             aedat       FROM zlmetext-aedat
             aenam       FROM zlmetext-aenam
             letter      FROM it_ltr_text
        TO DATABASE zlmetext(lm) ID text_idx.

This command is telling where to get the field values for the EXPORT to the Clustered Table


        TO DATABASE zlmetext(lm) ID text_idx.

This is telling it to export to the database ZLMETEXT (vs to Memory) with the RELID lm (which is NOT a variable, but the actual value stored in the RELID field).

ID text_idx tells it where to get the parts of the key you fill in.

Hope this helps.

TO DATABASE zlmetext(lm) ID text_idx.

Read only

0 Likes
1,151

by the way, this is the equivlent to a SELECT/READ for a Clustered Table


* Get Letter Body
  CLEAR text_idx.
  text_idx-appl     = zlmetext-appl.
  text_idx-letterid = zlmetext-letterid.
*  text_idx-srtf2    = 0.

  SELECT SINGLE srtf2 INTO text_idx-srtf2 FROM zlmetext
  WHERE  relid    EQ zlmetext-relid
    AND  appl     EQ zlmetext-appl
    AND letterid  EQ zlmetext-letterid.

  REFRESH it_ltr_text.
  CASE base_relid.
    WHEN c_lm_relid.
      IMPORT letter = it_ltr_text
        FROM DATABASE zlmetext(lm) ID text_idx.
    WHEN OTHERS.
  ENDCASE.

One very important thing to ensure is that when you EXPORT the clustered part, the name you give

(ie letter FROM it_ltr_text )

To retrieve this data, the value it_ltr_text MUST be used in both the EXPORT and IMPORT to successfull retrieve the proper cluster.

Edited by: Paul Chapman on Apr 25, 2008 4:04 PM

Read only

0 Likes
1,151

Again, here are examples of SAP code IMPORTing from PCL2


   import
     AR-VERSION TO OAR-VERSION                   "OBJECTS_FOR_IMPORT
     VERSC
     WPBP
     ABC
     RT
     CRT
     BT
     C0
     C1
     V0
     VCP
     ALP
     DFT
     GRT
     LS
     STATUS
     ARRRS
     DDNTK
     ACCR
     BENTAB
     AB
     FUND
     AVERAGE
     MODIF
     ARASFAM
     ARSES
     ARWPBP
     ARIMP
     ARCIMP
     ARDIMP
     AROIMP
     ARDIV
     ARTER
     ARPRVR
     ARPRVA
   from database PCL2(AR) id rx-key using pcl2_exp_imp.

and here, they are EXPORTing


   export
     AR-VERSION                                  "OBJECTS_FOR_EXPORT
     VERSC
     WPBP
     ABC
     RT
     CRT
     BT
     C0
     C1
     V0
     VCP
     ALP
     DFT
     GRT
     LS
     STATUS
     ARRRS
     DDNTK
     ACCR
     BENTAB
     AB
     FUND
     AVERAGE
     MODIF
     ARASFAM
     ARSES
     ARWPBP
     ARIMP
     ARCIMP
     ARDIMP
     AROIMP
     ARDIV
     ARTER
     ARPRVR
     ARPRVA
   to database PCL2(AR) id rx-key using pcl2_exp_imp.

I'm willing to bet you will not find them updating or inserting any other way then with IMPORT/EXPORT DATABASE.

Edited by: Paul Chapman on Apr 25, 2008 4:10 PM

Read only

0 Likes
1,151

Thx again for the reply. Can I do it like this?:

export

AR-VERSION = I_PCL2-AR-VERSION

VERSC = I_PCL2-VERSC

WPBP = I_PCL2-WPBP

................

to database PCL2.

My select goes like this:

Select * from PCL2 into I_PCL2 where STRFID = 00000038.

I_PCL2 contains the correct data so..

Read only

0 Likes
1,151

You're going to need more info in the EXPORT


  to database PCL2(AR) id rx-key using pcl2_exp_imp.   " AR is the actual value of the RELID field

That RELID is part of the KEY

To retrieve everythng except the Clustered portions, you can use SELECT, however, you MUST use IMPORT to retrieve the

clustered field(s).

Read only

0 Likes
1,151

Ok I'll leave it open till monday :d

Thanks again.

Greets