Skip to Content
0

ABAP code to "catch" current field value of currently opened transaction (FBCJ)

Oct 12, 2016 at 09:12 AM

184

avatar image

Hi experts,

in ABAP code of my ZReport (cash receipt of FBCJ transaction), I have simple ABAP code looking like this

SELECT SINGLE PERSON1 FROM TCJ_C_JOURNALS INTO usrname

but problem with this code is that it is missing WHERE part, which should look like this

SELECT SINGLE PERSON1 FROM TCJ_C_JOURNALS INTO usrname
WHERE CAJO_NUMBER = *currently selected cash journal on FBCJ Tcode
* (item no. 1 on screenshot)

Please see screenshot bellow.

https://s16.postimg.org/zark5oao5/2016_10_12_8_55_38.jpg

If I would need for example in WHERE clause, SAP username, I would easily use SY-UNAME which would read currently login username, BUT how about currently selected cash journal in FBCJ Tcode, is it possible to find such value so I could use it for my ABAP query?

Thank you.
Sam

10 |10000 characters needed characters left characters exceeded

Is a "selected cash journal" a username? Question makes little sense to me.

0

Hi Matthew,

"selected cash journal" if field on FBCJ Tcode, please see screenshot bellow. I have mention SY-UNAME just as an example, my mistake. Also this is the right code

SELECT SINGLE PERSON1 FROM TCJ_C_JOURNALS INTO prsname
WHERE CAJO_NUMBER = *currently selected cash journal on FBCJ Tcode
* (item no. 1 on screenshot)

i4rum.png (59.1 kB)
0
Show more comments
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Raymond Giuseppi
Oct 14, 2016 at 12:47 PM
0

Look in customizing of 'Financial Accounting Global Settings, Correspondence' for 'Cash document' in 'Define Correspondence Types', and then in either'SAPscript-Based Forms' or 'PDF-Based Forms', also (last and not least) 'Assign Programs for Correspondence Types'.


Regards,
Raymond

Share
10 |10000 characters needed characters left characters exceeded
Raymond Giuseppi
Oct 13, 2016 at 06:54 AM
0

Didn't you get the required information(s) in the signature of the form interface (ISCJ_POSTINGS-CAJO_NUMBER)?

Regards,

Raymond

Share
10 |10000 characters needed characters left characters exceeded
samnovice new Oct 13, 2016 at 09:08 AM
0

Hi Raymond,

thank you very much for useful reply.

No, because I can't manage to achieve that using my ABAP code. Please see my screenshot and code bellow. Since ISCJ_POSTINGS is structure and not actual table it doesn't contain any transactional data, I can't pull any data from it so I guess I have to find other way to pull data about *currently selected cash journal*?

Thank you so much for helping me with this issue.
Sam

https://s12.postimg.org/eibdxcm8t/2016_10_13_10_55_09.jpg


*&---------------------------------------------------------------------*
*& Form F_GETPERSON1NAME
*&---------------------------------------------------------------------*
* read the full person's name
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM F_GETPERSON1NAME TABLES int_cond STRUCTURE itcsy
outt_cond STRUCTURE itcsy.
DATA cajonum TYPE ISCJ_POSTINGS.
DATA person1name TYPE string.
person1name = ''.
* read the username:
* TCJ_C_JOURNALS contains PERSON1 and CAJO_NUMBER
* ADRP indice PERSNUMBER contains NAME_LAST NAME_FIRST name_text

SELECT SINGLE CAJO_NUMBER FROM ISCJ_POSTINGS INTO cajonum.

SELECT SINGLE PERSON1 FROM TCJ_C_JOURNALS INTO person1name
WHERE CAJO_NUMBER = cajonum.

READ TABLE outt_cond INDEX 1.
outt_cond-value = person1name.
MODIFY outt_cond INDEX 1.

ENDFORM. " F_GETPERSON1NAME

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Don't read from database, first identify the signature/parameters received in the form driver program (the structure should be there).

0

Hi Raymond,

thank you for useful suggestion.

I agree, it was amateur of me trying read from db. However, I am trying to follow your suggestion regarding "first identify the signature/parameters received in the form driver program" but I am confused because I am having trouble identifying driver program. Can you give me some pointers here please?

Thank you for your effort and trying to help me solve my issue.

Sam

0

Hi

You should indicate which Sapscript you're using

In SE71 try to go to Form->Check->Texts

The driver program is often shown here

1
max bianchi Oct 13, 2016 at 09:22 AM
0

Hi

It seems you're in a form for a sapscript so the CAJONUM should be transfered by it

That mean CAJONUM has to be available in your sapscript

Try to check in the structures or variable used by your sapscript if there's CAJONUM

Max

Share
10 |10000 characters needed characters left characters exceeded