cancel
Showing results for 
Search instead for 
Did you mean: 

Table Joins in GTS for fetching Declaration# from PO#

0 Kudos

Hello Gurus,

I wanted Table or a Table join which can fetch me the Declaration# if I input the PO# or Delivery# in GTS

Currently, using CUHD and LEGREF, I am able to retrieve PO# and Delivery# from a declaration#

But, I want vice-versa

I want to input PO# and retrieve the corresponding Declaration#

Any help is highly appreciated

I tried using CUHD, CUIT, CORFLO, LEGREF

Regards,

VK

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member215181
Active Contributor
0 Kudos

Hi Vineeet,

You need to use a table join - something like:

  SELECT SINGLE corder coyear

    INTO CORRESPONDING FIELDS OF es_cuhd_sk

    FROM /sapsll/cuhd

    JOIN /sapsll/corref ON guid_mobj = /sapsll/cuhd-guid_cuit

     AND /sapsll/corref~mobjt = /sapsll/cuhd~mobjt

    WHERE qalref = 'EXTIDF'

      AND objtp = 'BUS2012'

      AND orglogsys = iv_logsys

      AND refno = iv_po_num.

You should first transform the P.O. number using Function Module CONVERSION_EXIT_ALPHA_INPUT, so that the field (type /SAPSLL/REFNO) is filled with leading zeros as stored in the table.

I've replied quite literally to your question, but in practice you might want to work at Item level, since a single P.O. could be linked to more than one Customs Document.  And if you transfer P.O's and use Import Declarations, you might need further filtering (the QALREF value might change between 'EXTID' and 'EXTDIF' accordingly).

Hope that helps.

Regards,

Dave