cancel
Showing results for 
Search instead for 
Did you mean: 

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

samnovice_new
Participant
0 Kudos

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

matt
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi

How do you submit your custom program?

Max

samnovice_new
Participant
0 Kudos

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)

Accepted Solutions (1)

Accepted Solutions (1)

raymond_giuseppi
Active Contributor
0 Kudos

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

Answers (3)

Answers (3)

Former Member
0 Kudos

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

samnovice_new
Participant
0 Kudos

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

raymond_giuseppi
Active Contributor
0 Kudos

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

samnovice_new
Participant
0 Kudos

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

Former Member

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

raymond_giuseppi
Active Contributor
0 Kudos

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

Regards,

Raymond