Skip to Content

FI users often have to enter a series of document line items and then create an offsetting entry that is the total of the line items with the opposite sense so that the document nets to 0. (If the total is a credit, a debit entry must be added and vice versa.) But the user may not have the total at hand and would like to have the final entry determined without having to go to a calculator or a spreadsheet. If you create a document using say FB50, this can be done automatically by entering all the line items with the correct amounts except for the last item. For the last item, the user can enter a “*” in the amount and the program will calculate and populate the total after the user presses enter. If you find yourself being asked to do something similar, the following program should help to guide you along. 

Some Things to Note 

  • The program is not meant as a tutorial on dialogue programming. It assumes that you are already familiar with those concepts (including using table controls). If you are not, you should get some experience with screen programming before trying this.
  • The program is dirty. I have not taken a great deal of effort to add any extras or do any checking that would normally be done. This is another reason not to use this as a model dialogue program.
  • The program consists of one executable program with a screen and a GUI status.

 Getting Started 

  • Create a local program with type “1” (executable).
  • Copy the code below into the program

     

  • Double click on ‘9999’ in the line:    CALL SCREEN 9999.

  • This will take you the screen painter where you can create your screen.
  • I included a number of fields from the data dictionary object BSIS. You don’t need to use all of the ones that I did, but it should match your internal table and you will need at least BSIS-DMBTR and BSIS-SHKZG. They will need to be in a table control called MY_CTL. The screen type is “normal” and the next screen is just 9999.
  • When you copy the fields into the table control, take the default attributes.
  • Copy the following code into the flow logic for the screen.

  • Back in the program, double click on ‘STD’ in the line:  SET PF-STATUS ‘STD’.
  • This will take you to the user interface maintenance screen. You will need to create a simple GUI status here that allows you to get out of the screen. You can simply enter ‘CAN’ above the red “X” in the standard toolbar in the “Function keys”. Then click on the red “X” to bring up the function attributes. The Function type should be ‘E’ (exit command). The screen will then recognize the “cancel” button correctly.
  • Save and activate everything.
  • Test – you should be able to enter data in all fields. No real checking will be done now, but the screen should re-populate itself after the enter key is pressed.

 Seeing what’s going on

When you copied the field DMBTR from the data dictionary and kept the default attributes, the “* Entry” attribute was not clicked on. Now, when you execute the program and the screen comes up, enter a numeric value in the “Amount” field and press enter. There should be no problem doing this. Then try entering a non-numeric character (other than “*” or “-“) in the amount. You should find that the screen will not accept the entry at all. Finally, enter “*” in the amount (without the quotes) and press enter. Unlike a normal non-numeric character, you can enter this; however, when you press enter, you should get an error: “Input should be in the form __,___,___,__~.__”.

Now go back to the screen attributes and click on the “* Entry” attribute on the “program” tab of the attributes. Save and generate the screen. Go back and try entering the same data in the amount as you did earlier. You will find that it behaves similarly with a couple of exceptions: if you enter exactly one “*”, you will not get an error and the “*” will not be re-displayed; if you enter a “*” followed by a number, the number will be shifted left by one character so that the “*” again disappears.

This is the first thing you have to realize – clicking on the “* Entry” attribute will allow you to enter a “*” in a numeric field. Note that you can click this on for other fields and maybe you can use this in some way, but for now it is only relevant for this currency field. But what good is entering a “*” in a numeric field? Not much yet – the entry was simply removed. Now we are ready to look at the second important point:

  • Go back to the flow logic for the screen and notice that one line is commented out: *   FIELD bsis-dmbtr MODULE get_balance ON *-INPUT.
  • Remove the leading asterisk (un-comment the line back in).
  • Save and activate the screen

 Now you are ready to do a real test. In the first two lines, enter a debit/credit indicator of “S” (debit) and in the first line an amount of 100 and in the second one an amount of 200. On the third line, enter a “*” in the amount and press enter. If we’ve both done everything correctly, the first two lines will be re-displayed normally, but the third line will have “H” (credit) in the debit/credit indicator and an amount of 300. So the program was able to calculate and populate the amount and sense of an offsetting entry.

Some Further Things to Note 

  • You can enter a “*” in more than one line, but probably don’t want to allow your users to do so. It will just go on calculating totals and they may not be meaningful. It might be best to restrict the “*” to the last line only.
  • The last time I looked, transactions like FB50 allow “*” in more than one line. There are probably reasons for this, but they escape me.
  • Also the last time I looked, transactions like FB50 calculate the total correctly but not the debit credit indicator. So this may be an improvement
  • You are not restricted to calculating totals. I haven’t tried this, but you could probably use “ON *-INPUT” on other types of fields and have different types of special logic.
  • If you press F1 on MODULE, you will see some documentation for ON *-INPUT
  • This program and screen was developed in 4.7. I would expect similar results in different releases, but your results may vary.
To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

  1. Dany Dan
    Hi Rob,
    Thanks. its a good post infact. But it is not clear as to why it shows H300 instead of H100. If it shows H100 the user can easily guess that the credit balance entered is excess by 100 and can be corrected easily. This does not give clear picture about the offset entry correction. There is no use to show totals in this case.

    Thanks
    Dany

    (0) 
    1. Rob Burbank Post author
      Thanks Dany for your comment. The example I used for testing was meant to be very simple just to show that it works. In a real life situation, the user might have a large number of line items mixing debits and credits with no simple way of calculating the final amount. As I said in the
      Blog, this is similar functionality to that in FB50.

      Rob

      (0) 
  2. Anonymous
    Dear Bob,
         Thanx for sharing your contribution. It’s really useful for us.
    (0) 
    1. Rob Burbank Post author
      Thanks Santosh – I didn’t know about it either until a user asked me to make a screen that I had written work like FB50 in this regard. I did a bit of debugging and there it was.

      Rob

      (0) 
  3. Gangireddy Satti
    we modified the code of your program as follows
    module get_balance input.

    if cr_amt > dr_amt. ” Credit total
    bsis-dmbtr = cr_amt – dr_amt.
    bsis-shkzg = ‘S’. ” Offset with a debit
    clear: cr_amt, dr_amt. “<—change of code

    elseif dr_amt > cr_amt. ” Debit total
    bsis-dmbtr = dr_amt – cr_amt.
    bsis-shkzg = ‘H’. ” Offset with a credit
    clear: cr_amt, dr_amt. “<—change of code
    else. ” Already balanced
    message s001 with ‘Screen totals already 0’.
    endif.

    endmodule.

    with the above changes, i was able to place * at any record (except for the first)and got the result succesfully. but if i placed * at first record and press enter, message is populated that fields are set to zero.
    please guide me how to over come this.

    Thanks & Regards,
    S.Gangireddy.

    (0) 
    1. Rob Burbank Post author
      You have to bear in mind that the blog is meant to show that the functionality is there and how to use it.

      In your case (and I guess most others), I would simply put in logic to ensure that the “*” entry can only be put in the last record.

      Rob

      (0) 

Leave a Reply