This website is not affiliated with, sponsored by, or approved by SAP AG.

Select from partner table

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Select from partner table

Postby rpinxt » Mon Jun 22, 2015 9:28 am

So from table VEKP I want to get the corresponding Carrier from VBPA table.
In VEKP you have VPOBJKEY which is a reference to the delivery number.

So I made this code :
Code: Select all
CLEAR RP_CAR.
SELECT SINGLE LIFNR FROM VBPA
  INTO RP_CAR
  WHERE VBELN = VEKP-VPOBJKEY AND PARVW = 'TR'.


But it returns nothing.
However when I change LIFNR to KUNNR and take out PARVW part I do get the Customer number from VBPA.
(But there are 2 customer numbers and I only get the first!).

So the code must be working but I do not understand why it will not give me the LIFNR from VBPA (and yes there is a LIFNR).
Already thought about the TPAUM table but TR is also correct there is no other name.

Anybody know what else could be the problem?
Thanks!
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am

Re: Select from partner table

Postby Gothmog » Mon Jun 22, 2015 1:49 pm

Is there only one line with with partner function for this document in VBPA?
Select single only returns the first row found.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Select from partner table

Postby rpinxt » Tue Jun 23, 2015 2:37 am

No there is not.
There are 3 lines:
- First line has only customer no vendor.
- Second line has no customer only vendor.
- Third line has only customer (different then first line) and no vendor.

As said with the select single on customer number it will give me the First line (logically probably).

Now I tried a select for the vendor like this :
Code: Select all
CLEAR RP_CAR.
SELECT LIFNR FROM VBPA
  INTO RP_CAR
  WHERE VBELN = VEKP-VPOBJKEY AND PARVW = 'TR'.
ENDSELECT.


But still this gives nothing.

Just as a test I also tried this for the customers assuming I would get both customer lines :
Code: Select all
CLEAR RP_CAR.
SELECT KUNNR FROM VBPA
  INTO RP_CAR
  WHERE VBELN = VEKP-VPOBJKEY.
ENDSELECT.


However...this only gives me the third line!
So I can get the first line and I can get the third line....but I need the second line (and thus the Vendor line) :|
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am

Re: Select from partner table

Postby Gothmog » Tue Jun 23, 2015 3:03 am

When using SELECT...ENDSELECT, you're looping on the lines corresponding to your selection.
After the loop, of course you've got only the data of the last one.
Have a look at the help on SELECT, especially the additions SINGLE, INTO TABLE...
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Select from partner table

Postby rpinxt » Tue Jun 23, 2015 3:17 am

Thanks for this Gothmog.
But I just don't understand why Select Single won't work.
I have been using it so many times in other cases and it always worked.

Also there is only 1 line with partner funcion (PARVW) 'TR'.
So I would think with this line :
Code: Select all
WHERE VBELN = VEKP-VPOBJKEY AND PARVW = 'TR'.


Should give me what I want because it is the only line which meets the criteria.

Well...lets do so googling on Select then...
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am

Re: Select from partner table

Postby Gothmog » Tue Jun 23, 2015 3:24 am

It should - double-check the data in SE16N.

And I'd advise for F1 in the ABAP editor before googling.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Select from partner table

Postby rpinxt » Tue Jun 23, 2015 3:39 am

Yeah thats what I have been doing al time.
On 1 screen i have my SE16N data for this specific case and on the other sreen the code....
This is the SE16N data :
Doc Funct Cust/Ven
52140261 SP 122307
52140261 TR 1010515
52140261 SH 122312

So you see only 1 line which has TR.
Therefore with this code :
Code: Select all
CLEAR RP_CAR.
SELECT SINGLE LIFNR FROM VBPA
  INTO RP_CAR
  WHERE VBELN = VEKP-VPOBJKEY AND PARVW = 'TR'

I was expecting to find 1010515

Yes I was looking with F1 but was trying to find so examples in google what would work for me.
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am

Re: Select from partner table

Postby rpinxt » Tue Jun 23, 2015 4:25 am

Ok seems I have located the problem...

I tried now for the customer as there are 2 lines (SP and SH).
So I tried this :
Code: Select all
CLEAR RP_CAR.
SELECT SINGLE KUNNR FROM VBPA
  INTO RP_CAR
  WHERE VBELN = VEKP-VPOBJKEY AND PARVW = 'SP'.


But this also give me no output!
Where as without the part "AND PARVW = 'SP' " it will give the first lines customer.
So it does fill the customer.

But then my question would be, What is wrong with this part then:
Code: Select all
AND PARVW = 'SP'.


Does anybody undertand why PARVW SP or SH or TR would not work in this Select?
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am

Re: Select from partner table

Postby Gothmog » Tue Jun 23, 2015 4:35 am

'SP' should be 'AG' in internal format.
'SH' should be 'WE'.
'TR'... check TPAUM.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Select from partner table

Postby rpinxt » Tue Jun 23, 2015 4:55 am

Well in my initial mail I wrote I checked TPAUM....apparently not good enough.

But it is really confusing...'SP' is 'AG' ; 'SH' is 'WE' and 'TR'.....is 'SP'!
And on top of that.....TR for EN has 2 entries in TPAUM.
Yes the other entry is 'TR' is 'TR'....so thats what caught my eye at first and I thought, ok TR is TR so no changes....

Well thanks once more for pointing out the obvious Gothmog...works now :)
rpinxt
 
Posts: 146
Joined: Mon Jul 23, 2012 8:02 am


Return to ABAP

Who is online

Users browsing this forum: No registered users and 14 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.